swift pop实现动感按钮动画
// MyButton.swift
// PopInstall
//
// Created by su on 15/12/11.
// Copyright © 2015年 tian. All rights reserved.
//
import UIKit
class MyButton: UIButton {
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
//缩放动画
var scale = self.pop_animationForKey("scale") as? POPSpringAnimation
if scale != nil {
scale?.toValue = NSValue(CGPoint: CGPointMake(0.8, 0.8))
} else {
scale = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)
scale?.toValue = NSValue(CGPoint: CGPointMake(0.8, 0.8))
scale?.springBounciness = 20
scale?.springSpeed = 18
self.pop_addAnimation(scale, forKey: "scale")
}
//旋转动画 旋转是layer层动画
var rotate = self.layer.pop_animationForKey("ratate") as? POPSpringAnimation
if rotate != nil {
rotate?.toValue = M_PI / 6
} else {
rotate = POPSpringAnimation(propertyNamed: kPOPLayerRotation)
rotate?.toValue = M_PI / 6
rotate?.springBounciness = 20
rotate?.springSpeed = 18
self.layer.pop_addAnimation(rotate, forKey: "ratate")
super.touchesEnded(touches, withEvent: event)
if scale != nil {
scale?.toValue = NSValue(CGPoint: CGPointMake(1, 1))
} else {
scale = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)
scale?.toValue = NSValue(CGPoint: CGPointMake(1, 1))
scale?.springBounciness = 20
scale?.springSpeed = 18
self.pop_addAnimation(scale, forKey: "scale")
}
if rotate != nil {
rotate?.toValue = 0
rotate?.toValue = 0
rotate?.springBounciness = 20
rotate?.springSpeed = 18
self.layer.pop_addAnimation(rotate, forKey: "ratate")
swift pop实现动感按钮动画的更多相关文章
- POP按钮动画
POP按钮动画 效果 源码 https://github.com/YouXianMing/Animations // // ButtonPressViewController.m // Faceboo ...
- 8款超酷而实用的CSS3按钮动画
1.CSS3分享按钮动画特效 这是一款基于CSS3的社会化分享按钮,按钮非常简单,提供了分享到twitter.facebook.youtube等大型社交网站.每一个分享按钮都有个大社交网站的Logo图 ...
- 5个基于css3超炫的鼠标滑动按钮动画
今天给大家分享5个基于css3超炫的鼠标滑动按钮动画.这5个按钮鼠标经过的时候有超炫的动画效果.这5个按钮适用浏览器:360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之 ...
- Swift: 打造滑动解锁文字动画
原文:Swift: 打造滑动解锁文字动画 最近木事,找出来玩了玩facebook的paper.到处都是那个"slide to unlock your phone"的效果啊.忽闪忽闪 ...
- Swift - 多个mask的动画效果
Swift - 多个mask的动画效果 效果 源码 https://github.com/YouXianMing/Swift-Animations // // TranformFadeView.swi ...
- Swift - 用UIScrollView实现视差动画效果
Swift - 用UIScrollView实现视差动画效果 效果 源码 https://github.com/YouXianMing/Swift-Animations // // MoreInfoVi ...
- Swift - CALayer的contents属性动画
Swift - CALayer的contents属性动画 效果 源码 https://github.com/YouXianMing/Swift-Animations // // LiveImageVi ...
- 简单的UIButton按钮动画效果iOS源码
这个是简单的UIButton按钮动画效果案例,源码,简单的UIButton按钮动画,可以自定义button属性. 效果图: <ignore_js_op> 使用方法: 使用时把ButtonA ...
- 使用 Facebook开源动画库 POP 实现真实衰减动画
1. POP动画基于底层刷新原理.是基于CADisplayLink,1秒钟运行60秒,接近于游戏开发引擎 @interface ViewController () @property (nonatom ...
随机推荐
- mysql 源代码目录及安装目录介绍
1.源代码目录介绍: 1.BUILD BUILD目录是编译.安装脚本目录,绝大部分以compile-开头,其中的SETUP.sh脚本为C和C++编译器设置了优化选项.2.client cl ...
- Vue 获取数据、事件对象、todolist
vue中在方法里获取data里的msg:this.msg 在微信小程序里this.data.msg 改变data里的msg:this.msg="改变后的msg" 可以通过list. ...
- Vue 目录结构分析 数据绑定 绑定属性 循环渲染数据 数据渲染
一.目录结构分析 node_modules 项目所需要的各种依赖 src 开发用的资源 assets 静态资源文件 App.vue 根组件 main.js 配置路由时会用 .babelrc 配置文件 ...
- 给iOS开发新手送点福利,简述UIButton的属性和用法
UIButton属性 1.UIButton状态: UIControlStateNormal // 正常状态 UIControlStateHighlighted // 高 ...
- Django ORM-02
6.ForeignKey 相关操作 1.正向查找 正向查找:那么什么是正向查找,我们知道对于一对多或者多对一的情况,我们一般将ForeignKey设置在多的一边,比如我们的书籍与出版社一般是多对一的, ...
- ganglia-Monitor
- 串口通信,帧与帧之间的时间间隔问题?9600波特率,帧将各在20ms以上
- Maven(九)”编码 gbk 的不可映射字符“ 问题解决方案
解决这个问题的思路: 在maven的编译插件中声明正确的字符集编码编码——编译使用的字符集编码与代码文件使用的字符集编码一致!! 安装系统之后,一般中文系统默认字符集是GBK.我们安装的软件一般都继承 ...
- IBM X3650 M4 主板故障
故障描述: 今天突然接到报警,一台服务器无法连通,无法登录.无法 ping 通. 打电话到 IDC ,授权工程师查看服务器状态,返回结果如下: 1.服务器关机状态 2.无法开机 ( 电源灯亮 ),按开 ...
- cannot nest '/dubboService/src/main/resources' inside '/dubboService/src/main' .To enable the nesting exclude '/resources' from '/dubboService/src/main'
eclipse Maven--->update Project时出现以上错误: cannot nest '/dubboService/src/main/resources' inside '/d ...