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 ...
随机推荐
- zipkin:和springcloud集成过程记录
发现全是springcloudapp的名称,然后是springcloudapp(http://localhost:8080/hello/tom)工程单独调用并没有通知zipkin: 原来是因为rest ...
- CentOS 6.6下 BCM4312 802.11b/g无线网卡驱动安装
1.目前www.broadcom.com网站上最新版本为hybrid-v35,但此版本与2.6.32不匹配,无法识别验证密码,搜索网上说是要求升级内核,后根据http://www.dadclab.co ...
- bzoj2431逆序对数列
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2431 很容易想到n^3的做法.就是前 i 个数用第 i 个数最多能 i - 1 个逆序对,所 ...
- HttpHelp 请求帮助类
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...
- centos 6.5 单实例搭建 ELK
2018-07-02 21:32:33 ELK 单实例搭建 环境搭建 1.1我的系统版本 Distributor ID: CentOS Description: CentOS rele ...
- [搬运] [贪心]NOIP2011 观光公交
推荐这篇题解:http://www.cnblogs.com/Blacko/archive/2013/10/18/3376597.html 只不过这篇题解有一些细节没有说清,但建议自己思考- Codes ...
- python-web 创建一个输入链接生成的网站
第一步:写一个自定义程序 #coding=utf-8 import os #Python的标准库中的os模块包含普遍的操作系统功能import re #引入正则表达式对象import urllib # ...
- [转][javascript]判断传入参数
// IE 下 name 都是 undefined ,这里手动赋值 Number.name="Number"; //String.name="String"; ...
- c语言个人财务管理系统
这个是我的一个网上朋友写的,仅供大家参考: 在这里留个记录 #include<stdio.h>#include<string.h>#define null 0#define m ...
- webkit内核的浏览器为什么removeAttribute('style')会失效?
做了一些研究,应该算是理清了问题. 首先,我们在这里常说的「属性」(attributes)其实分为两种:内容属性(content attributes)以及 IDL 属性(IDL attributes ...