【swift3.0】-动画-抖动动画

本文探讨了为何大部分程序员难以转型成为架构师的原因,并附带介绍了一个简单的动画实现案例,以此来形象地说明技能专精的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

贡献作者 -【XJDomain】
博客XJ:  https://my.oschina.net/shengbingli/blog
GitHubhttps://github.com/lishengbing/XJQRCodeToolDemo

使用说明:

调用:

starAnim()

移除

stopAnim()

 / * 'key' may be any string such that only one animation per unique key
     * is added per layer. The special key 'transition' is automatically
     * used for transition animations. The nil pointer is also a valid key.
     *
 */
    /** Animation methods. **/
    open func add(_ anim: CAAnimation, forKey key: String?)

上面那个添加方法的注意⚠️:

参数key的作用:如果后面参数key传入:"rotation",可以保证添加动画的唯一性和只会添加一次,特别是在cell中添加这样的话,会保证cell不会复用

 

    fileprivate func starAnim() {
        // 1:创建动画对象
        let anim = CAKeyframeAnimation(keyPath: "transform.rotation")
        anim.values = [(-3 / 180 * M_PI), (3 / 180 * M_PI),(-3 / 180 * M_PI)]
        
        anim.repeatCount = Float(MAX_CANON)
        anim.duration = 1
        anim.autoreverses = true
        iconView.layer.add(anim, forKey: nil)
    }
fileprivate func stopAnim() {
        iconView.layer.removeAllAnimations()
    }

 

转载于:https://my.oschina.net/shengbingli/blog/792077

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值