//shrinking - scaling
CABasicAnimation* shrink = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
shrink.toValue = [NSNumber numberWithDouble:0.9];
shrink.duration = 0.5;
shrink.delegate = self;
[[targetView layer] addAnimation:shrink forKey:@"shrink"];
//moving
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
theAnimation.duration=0.1;
theAnimation.repeatCount=2;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:0];
theAnimation.toValue=[NSNumber numberWithFloat:-6];
[[targetView layer] addAnimation:theAnimation forKey:@"animateLayer"];
//rotating
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
theAnimation.duration=0.1;
theAnimation.repeatCount=1;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:0];
theAnimation.toValue=[NSNumber numberWithFloat:M_PI/3];
[[targetView layer] addAnimation:theAnimation forKey:@"rotateLayer"];
nice
ReplyDeletewhy does the size becomes the orignal after the completion of animation
ReplyDeleteif autoreserves value is set to YES the it will return original size, you can set it to NO
Delete