【发布时间】:2015-06-20 21:22:12
【问题描述】:
我试图让图像视图在 360 到 720 之间旋转随机度数。所以我希望图像视图旋转一次(360 度),然后再次旋转随机度数(0 到 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)
}
【问题讨论】:
-
第一:值应该是弧度,意思是 0 - 2PI 而不是 0 - 360。第二:您可能必须使用 CABasicAnimation 并指定它是附加动画。
-
@luk2302 - 我不知道该怎么做(?)
-
你不应该用
degree乘以一些东西。let rotate = diceRoll * degree或许? -
您尝试过的方法遇到了哪些问题?从其他 cmets 看来,您想找到我们的弧度和度数之间的差异,以及用于旋转的。
标签: ios swift uiviewanimation arc4random