Posted By

arpit on 11/06/10


Tagged

UIView UIColor


Versions (?)

Creating a gradient background in a UIView


 / Published in: Objective C
 

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

  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];

Report this snippet  

You need to login to post a comment.