swift -pop的简单动画

//1.新建空文件  命名Podfile
//2.写入 pod ‘pop’,’~>1.0’  保存
//3.打开终端,进入项目路径 执行pod install
//4.新建桥接头文件 导入#import <POP/POP.h>

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
       
        let redBall = UIView(frame: CGRect(x: 100, y: 100, 100, height: 100))
        redBall.backgroundColor = UIColor.redColor()
        redBall.layer.cornerRadius = 50
        self.view.addSubview(redBall)
       
        //实例化一个pop
        let scale = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)
        //设置结束时的值
       scale.toValue = NSValue(CGPoint: CGPointMake(2, 2))
        //弹性,振幅之类的属性,范围0-20
        scale.springBounciness = 20
        //震动速度,值越大动画结束越快,范围0-20
        scale.springSpeed = 1
        //pop对象关键字
        redBall.pop_addAnimation(scale, forKey: "scale")
        //x坐标位移动画
        let move = POPSpringAnimation(propertyNamed: kPOPLayerPositionY)
        move.toValue = 500
        move.springBounciness = 20
        move.springSpeed = 5
        redBall.layer.pop_addAnimation(move, forKey: "ilove")
       
        //旋转动画
        let spin = POPSpringAnimation(propertyNamed: kPOPLayerRotation)
        spin.toValue = M_PI * 4
        spin.springBounciness = 20
        spin.springSpeed = 5
        redBall.layer.pop_addAnimation(spin, forKey: "spin")
       
//        //背景颜色的变化
        let color = POPSpringAnimation(propertyNamed: kPOPLayerBackgroundColor)
        color.toValue = UIColor.greenColor()
        color.springBounciness = 20
        color.springSpeed = 5
        redBall.pop_addAnimation(color, forKey: "color")

       
        
    }
原文地址:https://www.cnblogs.com/tian-sun/p/5038986.html