Skip to content

Instantly share code, notes, and snippets.

@vixentael
Last active August 29, 2015 14:25
Show Gist options
  • Save vixentael/0fb84349202cbabc5679 to your computer and use it in GitHub Desktop.
Save vixentael/0fb84349202cbabc5679 to your computer and use it in GitHub Desktop.
ios view small animations
@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