Nil is not compatible with expected argument type

2019-03-10 14:14发布

I just started programming and following a tutorial online I was unable to create this animation. Can anyone tell me why it's saying:

Nil is not compatible with expected argument type UIViewAnimationOptions

and how to fix it?

view.addSubview(myFirstLabel)

UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.0, initialSpringVelocity: 0.0, options: nil, animations: {

    self.myFirstLabel.center = CGPoint(x: 100, y:40 + 200)

}, completion: nil)

2条回答
forever°为你锁心
2楼-- · 2019-03-10 14:39

UIViewAnimationOptions is an enum backed by integers. You should pass 0. Here is the doc for the enum.

查看更多
对你真心纯属浪费
3楼-- · 2019-03-10 14:54

You may replace options: nil with options: [] should make the error goes way.

Good luck !

查看更多
登录 后发表回答