Created
November 6, 2013 20:02
-
-
Save psobko/7343156 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basic QuartzCore Framework Animations | |
//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"]; | |
//time offset | |
theAnimation.beginTime = CACurrentMediaTime()+5; | |
//grouping | |
CABasicAnimation *makeBiggerAnim=[CABasicAnimation animationWithKeyPath:@"cornerRadius"]; | |
makeBiggerAnim.fromValue=[NSNumber numberWithDouble:20.0]; | |
makeBiggerAnim.toValue=[NSNumber numberWithDouble:40.0]; | |
CABasicAnimation *fadeAnim=[CABasicAnimation animationWithKeyPath:@"opacity"]; | |
fadeAnim.fromValue=[NSNumber numberWithDouble:1.0]; | |
fadeAnim.toValue=[NSNumber numberWithDouble:0.0]; | |
CABasicAnimation *rotateAnim=[CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; | |
rotateAnim.fromValue=[NSNumber numberWithDouble:0.0]; | |
rotateAnim.toValue=[NSNumber numberWithDouble:M_PI_4]; | |
// Customizing the group with duration etc, will apply to all the | |
// animations in the group | |
CAAnimationGroup *group = [CAAnimationGroup animation]; | |
group.duration = 0.2; | |
group.repeatCount = 3; | |
group.autoreverses = YES; | |
group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
group.animations = [NSArray arrayWithObjects:makeBiggerAnim, fadeAnim, rotateAnim, nil]; | |
[myLayer addAnimation:group forKey:@"allMyAnimations"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment