UIView Animation in Swift not working, invalid argument errors

I am trying to make an animation and use the code below. I get "Can't call" animateWithDuration "with a list of arguments like" (FloatLiteralConvertible, delay: FloatLiteralConvertible, options: UIViewAnimationOptions, animations :() โ†’ () โ†’ $ T4, completion: (Bool) โ†’ (Bool) โ†’ $ T5) "Error .

This means that I am using the wrong arguments. I could be wrong. Please help with this. I could not allow it.

var basketTopFrame = CGRect() basketTopFrame = dropPlace.frame var mytimer : NSTimer = NSTimer .scheduledTimerWithTimeInterval(2.0, target: self, selector: "restart", userInfo: nil, repeats: false) UIView.animateWithDuration(1.0, delay: 0.1, options: UIViewAnimationOptions.CurveEaseIn , animations: { var pickPlace = basketTopFrame }, completion: {(finished: Bool) in mytimer }) 

Thanks in advance.

+7
ios swift uiviewanimation
source share
1 answer

Closing has an automatic return if there is only one operator. Because of this, in your case, NSTimer returned, not Void . Your closed closure does not correspond to the closure of signatures. You must call the method on myTimer , for example, to fix this problem:

 UIView.animateWithDuration(1.0, delay: 0.1, options: UIViewAnimationOptions.CurveEaseIn, animations: { var pickPlace = basketTopFrame }, completion: { (finished: Bool) in mytimer.fire() } ) 
+13
source share

All Articles