Jane Jane - 1 year ago 44
iOS Question

Rotary wheel does not show the effect of ease In and ease Out

I have used the follwing code to rotate a wheel with 26 segments.The problem is that it is not showing the effect of easeIn and ease Out.

- (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/6.49);
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;

Answer Source

An EaseIn causes the animation to begin slowly and then speed up, this should happen only on first animation which is 0.5 sec, afterwards you use UIViewAnimationOptionCurveLinear and only for last animation you use EastOut.

As far as I can see code looks ok, are you sure you can see EaseIn effect in such a short time? Try to set longer duration and see does effect occur.