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 ...
随机推荐
- Maven(4)-利用intellij idea创建maven 多模块项目
本文通过一个例子来介绍利用maven来构建一个多模块的jave项目.开发工具:intellij idea. 一.项目结构 multi-module-project是主工程,里面包含两个模块(Modul ...
- DNS中NS和SOA区别
ns 授權很簡單… 假設你註冊的 domain 叫 abc.com ,而你有 ns1 與 ns2 兩台 server . 那,你必需從 .com 的權威伺服器授權給你,其設定或類似如此: $ORIGI ...
- 【monkeyrunner】monkeyrunner脚本录制和回放
脚本录制 1.连接你已经打开调试模式的ANDROID设备或模拟器,输入adb devices 2.运行录制脚本.在cmd窗口输入 monkeyrunner recorder.py #recorder. ...
- Could not write content: No serializer found for class and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )
1. 问题 org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: N ...
- jsp获取请求头信息
<%@ page language="java" import="java.util.*" contentType="text/html; ch ...
- 【Codeforces】Educational Codeforces Round 46(Contest 1000)
题目 传送门:QWQ A:Codehorses T-shirts 题意: 给定一些字符串表示去年和今年的衣服型号大小( XL XXL M...... ),要求用最少的次数把去年的衣服大小改成今年需要的 ...
- Autofac框架详解
一.组件 创建出来的对象需要从组件中来获取,组件的创建有如下4种(延续第一篇的Demo,仅仅变动所贴出的代码)方式: 1.类型创建RegisterType AutoFac能够通过反射检查一个类型,选择 ...
- 使用GridFsTemplate在Mongo中存取文件
Maven依赖(还有一些springboot需要的) <parent> <groupId>org.springframework.boot</groupId> ...
- 解决pip安装时的Readtime out问题
方法一 pip --default-timeout=100 install -U Pillow就可以了方法二 pip install pyinstaller -i https://pypi.douba ...
- 规则引擎以及blaze 规则库的集成初探之二——JSR94 的规则引擎API和实现
http://jefferson.iteye.com/blog/67839 规则引擎以及blaze 规则库的集成初探之二——JSR94 的规则引擎API和实现