
[英]How can I repeat animation (using UIViewPropertyAnimator) certain number of times?
[英]How to create animation which animate repeatedly with UIViewPropertyAnimator?
使用UIView.animate:方法,我们可以配置选项并将其设置为[.autoreverse,.repeat]。 这是一个简单的动画 :
@IBOutlet weak var v1: UIView!
UIView.animate(withDuration: 3, delay: 0, options: [.autoreverse,.repeat], animations: {
self.v1.frame = self.v1.frame.offsetBy(dx: 100, dy: 0)
}, completion: nil)
这段代码将对v1进行动画处理,反复地前后移动它,如何使用UIViewPropertyAnimator来做到这一点?( 我想利用stop和pause的优势 )
UIViewPropertyAnimator
没有提供重复动画的方法。 您需要使用旧的UIView
动画类方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.