Tuesday, May 8, 2012

Objective-C IOS development: Animations Autoreverse


I have a problem with the setting UIViewAnimationOptionAutoReverse. Here is my code.




CALayer *aniLayer = act.viewToChange.layer;
[UIView animateWithDuration:2.0 delay:1.0 options:(UIViewAnimationCurveLinear | UIViewAnimationOptionAutoreverse) animations:^{
viewToAnimate.frame = GCRectMake(1,1,100,100);
[aniLayer setValue:[NSNumber numberWithFloat:degreesToRadians(34)] forKeyPath:@"transform.rotation"];
} completion:nil ];



the problem is after the animation has reversed the UIView jumps back to the frame set in the animation block. I want the UIView to grow and "ungrow" and stop at it's original position.



is there a solution without programming 2 consecutive animations.



Thanks!


Source: Tips4all

No comments:

Post a Comment