//
//  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")

        }
    }
    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        super.touchesEnded(touches, withEvent: event)
        //缩放动画
        var scale = self.pop_animationForKey("scale") as? POPSpringAnimation
        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")
        }
        //旋转动画  旋转是layer层动画
        var rotate = self.layer.pop_animationForKey("ratate") as? POPSpringAnimation
        if rotate != nil {
            rotate?.toValue = 0
        } else {
            rotate = POPSpringAnimation(propertyNamed: kPOPLayerRotation)
            rotate?.toValue = 0
            rotate?.springBounciness = 20
            rotate?.springSpeed = 18
            self.layer.pop_addAnimation(rotate, forKey: "ratate")
        }
    }
}

swift pop实现动感按钮动画的更多相关文章

  1. POP按钮动画

    POP按钮动画 效果 源码 https://github.com/YouXianMing/Animations // // ButtonPressViewController.m // Faceboo ...

  2. 8款超酷而实用的CSS3按钮动画

    1.CSS3分享按钮动画特效 这是一款基于CSS3的社会化分享按钮,按钮非常简单,提供了分享到twitter.facebook.youtube等大型社交网站.每一个分享按钮都有个大社交网站的Logo图 ...

  3. 5个基于css3超炫的鼠标滑动按钮动画

    今天给大家分享5个基于css3超炫的鼠标滑动按钮动画.这5个按钮鼠标经过的时候有超炫的动画效果.这5个按钮适用浏览器:360.FireFox.Chrome.Safari.Opera.傲游.搜狗.世界之 ...

  4. Swift: 打造滑动解锁文字动画

    原文:Swift: 打造滑动解锁文字动画 最近木事,找出来玩了玩facebook的paper.到处都是那个"slide to unlock your phone"的效果啊.忽闪忽闪 ...

  5. Swift - 多个mask的动画效果

    Swift - 多个mask的动画效果 效果 源码 https://github.com/YouXianMing/Swift-Animations // // TranformFadeView.swi ...

  6. Swift - 用UIScrollView实现视差动画效果

    Swift - 用UIScrollView实现视差动画效果 效果 源码 https://github.com/YouXianMing/Swift-Animations // // MoreInfoVi ...

  7. Swift - CALayer的contents属性动画

    Swift - CALayer的contents属性动画 效果 源码 https://github.com/YouXianMing/Swift-Animations // // LiveImageVi ...

  8. 简单的UIButton按钮动画效果iOS源码

    这个是简单的UIButton按钮动画效果案例,源码,简单的UIButton按钮动画,可以自定义button属性. 效果图: <ignore_js_op> 使用方法: 使用时把ButtonA ...

  9. 使用 Facebook开源动画库 POP 实现真实衰减动画

    1. POP动画基于底层刷新原理.是基于CADisplayLink,1秒钟运行60秒,接近于游戏开发引擎 @interface ViewController () @property (nonatom ...

随机推荐

  1. stacks and queues--codility

    lesson 7: stacks and queues 1. Nesting 2. StoneWall 3. Brackets 4. Finsh lesson 7: stacks and queues ...

  2. bzoj1037生日聚会

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1037 任意区间的话,可以从所有后缀区间考虑. 因为每一个区间一定是某一时刻的一个后缀区间,所 ...

  3. logstash使用分享

    1.logstash时间处理函数 当业务场景需要自有的time字段覆盖@timestamp字段的情况下 需要使用 date { match => ["time", " ...

  4. java 线程池 ExeutorService

    Java线程池 ExecutorService 原文:https://blog.csdn.net/suifeng3051/article/details/49443835/ 本篇主要涉及到的是java ...

  5. Bootstrap-Plugin:标签页(Tab)插件

    ylbtech-Bootstrap-Plugin:标签页(Tab)插件 1.返回顶部 1. Bootstrap 标签页(Tab)插件 标签页(Tab)在 Bootstrap 导航元素 一章中介绍过.通 ...

  6. Building a Simple User Interface(创建一个简单的用户界面)

    对于一个android 应用程序,用户的图形界面通常是由View(视图)和ViewGroup(视图组)对象构成的层次结构. View(视图)对象通常是按钮或文本输入框这类UI小部件,ViewGroup ...

  7. Django中的Model、Form和ModelForm

    一  Model(数据库操作) 1 数据表操作 两种类型: Code First:创建类→自动生成表 DB First:创建表→自动生成类 (很少用) 单表操作: 一对多:(Forienkey) 多对 ...

  8. leetcode26

    public class Solution { public int RemoveDuplicates(int[] nums) { var len = nums.Length; ) { ; } els ...

  9. AES 加密算法 跨语言

    aes加密算法 delphi .java.c# .网页在线工具 4个相同 AES/ECB/PKCS5Padding 与网页在线工具加密结果相同 http://tool.chacuo.net/crypt ...

  10. C++builder XML XSL 代码生成

    void __fastcall TFrmGenCode::XSLTxml1Click(TObject *Sender) { // XSLT转换xml文件格式 _di_IXMLDocument xml; ...