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 ...
随机推荐
- ETL流程概述及常用实现方法
ETL流程概述及常用实现方法 http://blog.csdn.net/btkuangxp/article/details/48224187 目录(?)[-] 1抽取作业 1手工开发抽取作业时候的常用 ...
- PSI分析
"SI是对多个TS流的描述,它包含了PSI" PSI只提供了单个TS流的信息,使接收机能够对单个TS流中的不同节目进行解码:但是,它不能提供多个TS流的相关业务,也不能提供节目的类 ...
- ASI和TS流有什么区别
TS流是信源码流,最高码率为44.209 Mbit/s,它是经过信源编码后的压缩码流,为了使欲传输的信源信息在传输速率一定的条件下更快更多地传输,还要把数据进行压缩,也就是通过信源编码去掉信息中多余的 ...
- 微信小程序获取用户openid,头像昵称信息,后台java代码
https://blog.csdn.net/qq_39851704/article/details/79025557
- [Python] String strip() Method
Description The method strip() returns a copy of the string in which all chars have been stripped fr ...
- leetcode434
public class Solution { public int CountSegments(string s) { s = s.Trim(); ) { ; } else { ; ; ; i &l ...
- sudo免密码
很多都是修改/etc/sudoers权限为740再加上一句 ALL=NOPASSWD:ALL 或者加一句 yourname ALL=(ALL) NOPASSWD: ALL 然后权限改回440 先说第一 ...
- javascript数组操作(创建、元素删除、数组的拷贝)
这篇文章主要介绍了javascript数组操作,包括创建.元素的访问.元素删除.数组的拷贝等操作,还有其它示例,需要的朋友可以参考下 1.数组的创建 复制代码 代码如下: var arrayObj = ...
- 值类型 struct
由于值类型存在装箱和拆箱的过程,所有导致在修改值类型对象内部数据时,有可能会出现一些与预想不同的结果. 比如 Point p = , ); Console.WriteLine(p); p.Change ...
- Selection Tools
[Selection Tools] 1.Marquee Tools. OptionBar其中四年控件涵意如下: 2.Magnetic Lasso Tool,根据属标轨迹自动画点. 3.Magic Wa ...