Mor*_*son 39 uiviewanimation swift
如何在动画块中设置UIViewAnimationOptions
to :.Repeat
UIView
UIView.animateWithDuration(0.2, delay:0.2 , options: UIViewAnimationOptions, animations: (() -> Void), completion: (Bool) -> Void)?)
Run Code Online (Sandbox Code Playgroud)
nsc*_*hum 104
和以前差不多:
UIView.animate(withDuration: 0.2, delay: 0.2, options: UIViewAnimationOptions.repeat, animations: {}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
除了你可以省略完整类型:
UIView.animate(withDuration: 0.2, delay: 0.2, options: .repeat, animations: {}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
你仍然可以结合选项:
UIView.animate(withDuration: 0.2, delay: 0.2, options: [.repeat, .curveEaseInOut], animations: {}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
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)
Run Code Online (Sandbox Code Playgroud)
Kyl*_*len 13
在Swift 2.0之前的大多数Cocoa Touch'选项'集合现在都被改为结构,UIViewAnimationOptions
就是其中之一.
而UIViewAnimationOptions.Repeat
这在以前已经被定义为:
(半伪代码)
enum UIViewAnimationOptions {
case Repeat
}
Run Code Online (Sandbox Code Playgroud)
它现在定义为:
struct UIViewAnimationOption {
static var Repeat: UIViewAnimationOption
}
Run Code Online (Sandbox Code Playgroud)
重点是,为了实现之前使用bitmasks(.Reverse | .CurveEaseInOut
)所实现的功能,您现在需要将选项放在数组中,可以直接放在options
参数之后,也可以在使用之前在变量中定义:
UIView.animateWithDuration(0.2, delay: 0.2, options: [.Repeat, .CurveEaseInOut], animations: {}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
要么
let options: UIViewAnimationOptions = [.Repeat, .CurveEaseInOut]
UIView.animateWithDuration(0.2, delay: 0.2, options: options, animations: {}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅user @ 0x7fffffff的以下答案:Swift 2.0 - 二进制运算符"|"不能应用于两个UIUserNotificationType操作数
归档时间: |
|
查看次数: |
42085 次 |
最近记录: |