Я пытаюсь сделать эффект «Spin the wheel» в приложении, и я могу заставить бутылку вращаться, но он останавливается в том же положении. Как я могу остановить его случайным образом? Спасибо всемButton spin in IO
Вот код:
- (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"];
}
Спасибо большое! Это сработало, но я сделал это по-другому. Нечто подобное - (IBAction) btnRotate: (ID) отправитель { [UIView animateWithDuration: 0.7 анимации:^{ imgRotate.transform = CGAffineTransformMakeRotation (arc4random()/((POW (2, 2) -0.2)) * M_PI * 400); }]; – user2792520