Created
October 26, 2013 15:35
-
-
Save rais38/7170792 to your computer and use it in GitHub Desktop.
Add gradient animation
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
- (void)addGradientAnimation | |
{ | |
UIColor *color1 = [UIColor redColor]; | |
UIColor *color2 = [UIColor yellowColor]; | |
UIColor *color3 = [UIColor grayColor]; | |
CAGradientLayer *gradient = [CAGradientLayer layer]; | |
gradient.frame = self.view.frame; | |
gradient.colors = @[(id)color1.CGColor, (id)color2.CGColor, (id)color2.CGColor]; | |
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"colors"]; | |
animation.toValue = @[(id)color3.CGColor, (id)color1.CGColor, (id)color1.CGColor]; | |
animation.duration = 3.0; | |
animation.autoreverses = YES; | |
animation.repeatCount = HUGE_VALF; | |
[gradient addAnimation:animation forKey:@"colors"]; | |
[self.view.layer addSublayer:gradient]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment