ica*_*ama 3 arrays animation ios swift swift2
我对arraySwift 2 中的动画选项有一些问题。我可以array像这样添加多个选项:[.Repeat, UIViewAnimationOptions.Autoreverse]这是如果我添加动画功能(第一个示例):
UIView.animateWithDuration(1, delay: 0, options: [.Repeat, UIViewAnimationOptions.Autoreverse], animations: {
}) { (true) in
}
Run Code Online (Sandbox Code Playgroud)
但我不能array像这样添加动画选项(第二个例子):
var animationOptions = [UIViewAnimationOptions]()
animationOptions.append(UIViewAnimationOptions.Repeat)
animationOptions.append(UIViewAnimationOptions.Autoreverse)
UIView.animateWithDuration(1, delay: 0, options: animationOptions, animations: {
}) { (true) in
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我像第二个例子那样在数组中制作动画选项吗?
var animationOptions:UIViewAnimationOptions = .repeat
animationOptions.insert(.autoreverse)
UIView.animate(withDuration: 0.1, delay: 0.1, options: animationOptions, animations: {
}) { (success:Bool) in
}
Run Code Online (Sandbox Code Playgroud)
您需要使用来自 SetAlgebra 协议的插入,OptionSet 符合该协议。在问题中,您使用的是数组对象而不是 UIViewAnimationOptions。