在Swift 2中设置animateWithDuration中的选项

时间:2015-07-21 13:21:39

标签: uiview swift2 animatewithduration

我使用以下代码为文本字段设置动画:

UIView.animateWithDuration(0.5, delay: 0.4,
        options: .Repeat | .Autoreverse | .CurveEaseOut, animations: {
            self.password.center.x += self.view.bounds.width
        }, completion: nil)

我收到错误Could not find member 'Repeat'

只有在我只设置一个选项时,代码才有效。 为什么不让我设置多个选项?

1 个答案:

答案 0 :(得分:10)

组合OptionSetType的语法已更改,您可以这样做:

UIView.animateWithDuration(0.5, delay: 0.4,
    options: [.Repeat, .CurveEaseOut, .Autoreverse], animations: {
        self.password.center.x += self.view.bounds.width
    }, completion: nil)