我正在尝试在应用程序中制作这种“旋转轮子”效果,我让瓶子旋转,但它停在同一个位置。我怎样才能让它随机停止?谢谢你们
这里的代码:
- (IBAction)spin:(id)sender {
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath: @"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 0.5;
fullRotation.repeatCount = 2;
[button.layer addAnimation:fullRotation forKey:@"360"];
}