Skip to content

Instantly share code, notes, and snippets.

@yfujiki
Created February 11, 2013 02:03
Show Gist options
  • Save yfujiki/4751971 to your computer and use it in GitHub Desktop.
Save yfujiki/4751971 to your computer and use it in GitHub Desktop.
Easily add linear gradient on UIView
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil];
[view.layer insertSublayer:gradient atIndex:0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment