Hi,
I am a self taught noob with a real interest in code. Please excuse any wrong terminology
I have multiple animation blocks that I want to reuse through out my app, in mulitple views and multiple layers/buttons.
So how do I do the following:
- Create an "animation class" that all my views can access.
- Adjust my code so any layer can use it.(see my example code) As you can see this animation is for a specific layer.
Thank you!
- (CAAnimation*) lbFullAnimIn {
CAKeyframeAnimation *boundsOvershootAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CATransform3D startingScale = CATransform3DScale (lbFullButton.layer.transform, 0.8, 0.8, 0.8);
CATransform3D overshootAScale = CATransform3DScale (lbFullButton.layer.transform, 1.05, 1.05, 1.05);
CATransform3D undershootScale = CATransform3DScale (lbFullButton.layer.transform, 0.97, 0.97, 0.97);
CATransform3D overshootBScale = CATransform3DScale (lbFullButton.layer.transform, 1.01, 1.01, 1.01);
CATransform3D endingScale = lbFullButton.layer.transform;
NSArray *boundsValues = [NSArray arrayWithObjects:[NSValue valueWithCATransform3D:startingScale],
[NSValue valueWithCATransform3D:overshootAScale],
[NSValue valueWithCATransform3D:undershootScale],
[NSValue valueWithCATransform3D:overshootBScale],
[NSValue valueWithCATransform3D:endingScale], nil];
[boundsOvershootAnimation setValues:boundsValues];
NSArray *times = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f],
[NSNumber numberWithFloat:0.1f],
[NSNumber numberWithFloat:0.3f],
[NSNumber numberWithFloat:0.6f],
[NSNumber numberWithFloat:1.0f], nil];
[boundsOvershootAnimation setKeyTimes:times];
NSArray *timingFunctions = [NSArray arrayWithObjects:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
nil];
[boundsOvershootAnimation setTimingFunctions:timingFunctions];
boundsOvershootAnimation.fillMode = kCAFillModeForwards;
boundsOvershootAnimation.duration = 0.5;
boundsOvershootAnimation.removedOnCompletion = NO;
return boundsOvershootAnimation;
}