swift 快速奔跑的兔几 本节的内容是:animations
发布时间:2020-12-14 01:40:41 所属栏目:百科 来源:网络整理
导读:iOS 上的动画API基于闭包,例如要实现一个持续3秒的背景渐变效果: UIView.animateWithDuration(3){ () - Void in self.view.backgroundColor = UIColor.grayColor() } 如果希望把许多不同的动画全部链接在一个特定的序列内,并在指定时刻进行,我们可以这样
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") } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |