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


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.