Creating a gradient background in a UIView


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  1. UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease];
  2. CAGradientLayer *gradient = [CAGradientLayer layer];
  3. gradient.frame = view.bounds;
  4. gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil];
  5. [view.layer insertSublayer:gradient atIndex:0];

URL: http://stackoverflow.com/questions/422066/gradients-on-uiview-and-uilabels-on-iphone/1931498#1931498

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.