I have a CALayer to animate a change in its image contents. Now, how can I change how long it takes for this animation to take place?
It's more or less simple. You have an ivar CALayer *yourLayer
. Then you set the delegate and implement the delegate method -(id
- (void)awakeFromNib {
yourLayer.delegate = self;
yourLayer.name = @"yourLayer";
}
- (id )actionForLayer:(CALayer *)layer forKey:(NSString *)event {
if([layer.name isEqualToString yourLayer.name]) { // Check for right layer
CABasicAnimation *ani = [CABasicAnimation animationWithKeyPath:event]; // Default Animation for 'event'
ani.duration = .5; // Your custom animation duration
return ani;
} else return nil; // Default Animation
}