如何在UIView动画块中将UIViewAnimationOptions设置为.Repeat:

UIView.animateWithDuration(0.2, delay:0.2 , options: UIViewAnimationOptions, animations: (() -> Void), completion: (Bool) -> Void)?)

推荐答案

Swift 3

和以前差不多:

UIView.animate(withDuration: 0.2, delay: 0.2, options: UIViewAnimationOptions.repeat, animations: {}, completion: nil)

除了可以省略完整类型之外:

UIView.animate(withDuration: 0.2, delay: 0.2, options: .repeat, animations: {}, completion: nil)

您仍然可以组合选项:

UIView.animate(withDuration: 0.2, delay: 0.2, options: [.repeat, .curveEaseInOut], animations: {}, completion: nil)

Swift 2

UIView.animateWithDuration(0.2, delay: 0.2, options: UIViewAnimationOptions.Repeat, animations: {}, completion: nil)

UIView.animateWithDuration(0.2, delay: 0.2, options: .Repeat, animations: {}, completion: nil)

UIView.animateWithDuration(0.2, delay: 0.2, options: [.Repeat, .CurveEaseInOut], animations: {}, completion: nil)

Swift相关问答推荐

如何消除SwiftUI中SF符号的填充

有没有一种方法可以迭代可编码的代码(例如,JSON解析中的每一项)?

如何使泡泡上的箭头直达封闭矩形

在Swift中,将秒设置为0也等于将1添加到分钟

如何将多个完成处理程序转换为异步?

Observable.create 捕获行为

允许为 self 分配新的 struct 值的理由是什么?

如何在 switch case 模式语句中使用 Swift 文字正则表达式?

MacOS KIND 是如何实现的

从 Swift 列表中的行中检索值

Swift UI 不重绘 NSViewRepresentable 包装的文本字段

使用 Date.ParseStrategy 将字符串解析为日期

Swift:连接两个数组而不重复共享后缀/前缀

如何使用 Date.ParseStrategy 在 Swift 5.6 中将字符串解析为日期?

Swift - 如何更新多目录中的对象

如何在 Xcode 中的 UITests 下以通用方式访问后退栏按钮项?

无法使用锚激活约束

如何在 SwiftUI 中实现 PageView?

即使设置为从不也可以访问 iOS11 照片库

如何在Swift中找出字母是字母数字还是数字