Last active
August 29, 2015 14:25
-
-
Save vixentael/0fb84349202cbabc5679 to your computer and use it in GitHub Desktop.
ios view small animations
This file contains 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
@implementation UIView (SFLayerAnimation) | |
- (void)sf_animateFadeTransitionWithDuration:(CGFloat)duration delay:(CGFloat)delay name:(NSString *)name { | |
CATransition * animation = [CATransition animation]; | |
animation.timeOffset = delay; | |
animation.duration = duration; | |
animation.type = kCATransitionFade; | |
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
[self.layer addAnimation:animation forKey:name]; | |
} | |
- (void)sf_animateBackgroundColor:(UIColor *)color duration:(CGFloat)duration delay:(CGFloat)delay { | |
[UIView animateWithDuration:duration | |
delay:delay | |
options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut | |
animations:^{ | |
self.layer.backgroundColor = color.CGColor; | |
} completion:nil]; | |
} | |
- (void)sf_animateJumpToScale:(CGFloat)scale duration:(CGFloat)duration delay:(CGFloat)delay { | |
self.transform = CGAffineTransformMakeScale(scale, scale); | |
[UIView animateWithDuration:duration | |
delay:delay | |
options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionCurveEaseInOut | |
animations:^{ | |
self.transform = CGAffineTransformIdentity; | |
} completion:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment