Rotary Wheel stopping at every 90 degree sector only iOS

Multi tool use
Rotary Wheel stopping at every 90 degree sector only iOS
I have made a rotary wheel of 26 sectors. I want the rotary wheel to stop randomly at any of the sectors whereas it is only stopping at every 90 degrees sector (on sector # 0,6,13,20). This is my code snippet.
// an ivar for your class:
BOOL animating;
- (void) spinWithOptions: (UIViewAnimationOptions) options {
// this spin completes 360 degrees every 2 seconds
[UIView animateWithDuration: 0.5f
delay: 0.0f
options: options
animations: ^{
self.imageToMove.transform = CGAffineTransformRotate(imageToMove.transform, M_PI / 2);
}
completion: ^(BOOL finished) {
if (finished) {
if (animating) {
// if flag still set, keep spinning with constant speed
[self spinWithOptions: UIViewAnimationOptionCurveLinear];
} else if (options != UIViewAnimationOptionCurveEaseOut) {
// one last spin, with deceleration
[self spinWithOptions: UIViewAnimationOptionCurveEaseOut];
}
}
}];
}
- (void) startSpin {
if (!animating) {
animating = YES;
[self spinWithOptions: UIViewAnimationOptionCurveEaseIn];
}
}
- (void) stopSpin {
// set the flag to stop spinning after one last 90 degree increment
animating = NO;
}
Please tell me how to make it stop randomly every time it spins.
Thanks for the help. It works :)
– Jane
Aug 1 '16 at 10:24
Hi, if i implement your solution the animation of the wheel does not look real time. i.e ease in and ease out effect is not showing.Any suggestion?
– Jane
Aug 6 '16 at 11:04
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
26 segments is tricky since 360/26 isn't a whole number. You transform rotates by Pi/2 radians (90 degrees) each time. You need to rotate by 13.8461 degrees each time which is approximately M_PI_2/6.49 radians
– Paulw11
Jul 31 '16 at 12:35