Skip to content

Instantly share code, notes, and snippets.

@IvanovDeveloper
Created March 30, 2016 08:51
Show Gist options
  • Save IvanovDeveloper/b910e0dce126fc44461f16d735991b72 to your computer and use it in GitHub Desktop.
Save IvanovDeveloper/b910e0dce126fc44461f16d735991b72 to your computer and use it in GitHub Desktop.
Configure gradient for view
- (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