swift - 如何使用 UIViewPropertyAnimator 创建重复动画的动画?

标签 swift ios-animations 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 来做到这一点?(我想利用停止和暂停的优势)

最佳答案

UIViewPropertyAnimator 不提供重复动画的方法。您需要使用旧的 UIView 动画类方法。

关于swift - 如何使用 UIViewPropertyAnimator 创建重复动画的动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48944444/

相关文章:

iOS 13 替代 'setAnimationCurve'

ios - 扩展 UIViewControllerAnimatedTransitioning 时出现段错误

ios - UIViewPropertyAnimator 不会停止在 stopAnimation 上

ios - 当高度改变时 UINavigationController 会切断内容吗? (动图)

ios - 观察 UIViewPropertyAnimator 运行问题

ios - 使用 UIViewPropertyAnimator 通过触摸中断动画

ios - 如何实现代码以在 Swift for iOS 中在 MapKit 中进行可拖动的注释?

ios - 如何在 Swift 中呈现 iOS UIActionSheet?

iOS 图表 : Combined data into stacked bar chart?

ios - AFHTTPSessionManager 子类 swift