Created
March 30, 2016 08:51
-
-
Save IvanovDeveloper/b910e0dce126fc44461f16d735991b72 to your computer and use it in GitHub Desktop.
Configure gradient for view
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)configureGradientView:(UIView *)aView { | |
CAGradientLayer *gradient = [CAGradientLayer layer]; | |
gradient.frame = aView.bounds; | |
gradient.colors = @[(id)[UIColor colorWithWhite:0.f alpha:0.01f].CGColor, | |
(id)[UIColor colorWithWhite:0.f alpha:0.02f].CGColor, | |
(id)[UIColor colorWithWhite:0.f alpha:0.03f].CGColor, | |
(id)[UIColor colorWithWhite:0.f alpha:0.2f].CGColor, | |
(id)[UIColor colorWithWhite:0.f alpha:0.3f].CGColor, | |
(id)[UIColor colorWithWhite:0.f alpha:1.f].CGColor, | |
(id)[UIColor colorWithWhite:0.f alpha:1.f].CGColor]; | |
gradient.locations = @[@0.0f, | |
@0.1f, | |
@0.2f, | |
@0.3f, | |
@0.4f, | |
@0.6, | |
@1.f]; | |
aView.backgroundColor = [UIColor clearColor]; | |
[aView.layer insertSublayer:gradient atIndex:0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment