Last active
August 29, 2015 14:01
-
-
Save izackp/8cc055038f361e2a704d to your computer and use it in GitHub Desktop.
Creates a gradient for a view in code (IOS)
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
//By: Brandon Levasseur | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
CAGradientLayer *gradientLayer = [CAGradientLayer layer]; | |
gradientLayer.frame = self.containerView.bounds; | |
[self.view.layer addSublayer:gradientLayer]; | |
gradientLayer.colors = @[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor yellowColor].CGColor, (__bridge id)[UIColor greenColor].CGColor]; | |
gradientLayer.locations = @[@0.0, @0.25, @0.5]; | |
gradientLayer.startPoint = CGPointMake(0, 0); | |
gradientLayer.endPoint = CGPointMake(1, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment