CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
theAnimation.duration=0.1f;
theAnimation.removedOnCompletion = NO;
theAnimation.delegate = self;
theAnimation.fromValue = [NSNumber numberWithFloat:1];
theAnimation.toValue = [NSNumber numberWithFloat:0];
[theAnimation setValue:@"Throb" forKey:@"MyAnimationType"];
[view.layer addAnimation:theAnimation forKey:@"animateTransform"];
代理方法处理:
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
NSString* value = [theAnimation valueForKey:@"MyAnimationType"];
if ([value isEqualToString:@"Throb"]){
//... Your code here ...
;
return;
}
}