Life would be so much simple if we don't care so much

Posts tagged ‘gradient uiview’

How To Set Gradient For UIView

First, remember to import class framework package

#import <QuartzCore/QuartzCore.h>

Then add this:

UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] 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];