I am trying to get the image view to rotate random degree between 360 and 720. So I want the image view to rotate once(360 degrees), and then again rotate a random degree(0 to 360)
func rotateRandom2(){
let lower : UInt32 = 360
let upper : UInt32 = 720
let diceRoll = CGFloat(arc4random_uniform(upper - lower) + lower)
let degree = 0.0174532925 as CGFloat
let rotate = diceRoll
UIView.animateWithDuration(1, delay: 0.0, options: UIViewAnimationOptions.CurveEaseOut, animations: { () -> Void in
self.bottleImageView.transform = CGAffineTransformRotate(self.bottleImageView.transform, rotate)
}, completion: nil)
}
You can use CABasicAnimation to animate z rotation. You can do as follow: