swift 快速奔跑的兔几 本节的内容是:animations

前端之家收集整理的这篇文章主要介绍了swift 快速奔跑的兔几 本节的内容是:animations前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

iOS 上的动画API基于闭包,例如要实现一个持续3秒的背景渐变效果


        UIView.animateWithDuration(3){ () -> Void in
            self.view.backgroundColor = UIColor.grayColor()
        }

如果希望把许多不同的动画全部链接在一个特定的序列内,并在指定时刻进行,我们可以这样做:
        UIView.animateKeyframesWithDuration(6,delay: 0,options: UIViewKeyframeAnimationOptions.LayoutSubviews,animations: { () -> Void in
            UIView.addKeyframeWithRelativeStartTime(0,relativeDuration: 3,animations: { () -> Void in
                 self.view.backgroundColor = UIColor.magentaColor()
            })
            UIView.addKeyframeWithRelativeStartTime(0,animations: { () -> Void in
                self.view.backgroundColor = UIColor.grayColor()
            })
            }) { (Bool) -> Void in
            print("animation completed")
        }
原文链接:https://www.f2er.com/swift/325515.html

猜你在找的Swift相关文章