So what I need is an image to rotate continuously. The problem is at /// UIView.animateWithDuration() (0.01, animations: { ///
where it says: Could not find an overload for 'animateWithDuration' that accepts the supplied arguments
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let schedule = NSTimer.scheduledTimerWithTimeInterval(0.01, target: self, selector: Selector("rotate"), userInfo: nil, repeats: true)
schedule.fire()
func rotate() {
angle = angle + 1
UIView.animateWithDuration() (0.01, animations: {
self.imageView.transform = CGAffineTransformMakeRotation( ((self.angle) / 180.0 * M_PI));
})
}
}
@IBOutlet var imageView : UIImageView
var angle = 0
Thanks in advance.
As @Bryan Chen pointed out, you have an extra () in the method call. But, that's not your only problem. Your angle variable is an Int, when it's expected to be a Double which causes this error. Change your variable declaration to be a Double
var angle = 0.0
And use doubles throughout, like when modifying the variable.
angle = angle + 1.0
And then this will work without error.
UIView.animateWithDuration(0.01, animations: {
self.imageView.transform = CGAffineTransformMakeRotation( ((self.angle) / 180.0 * M_PI));
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With