If I have two UIColors, what\'s the best way to draw an even gradient between them over an arbitrarily-sized area?
I am guessing you would create a UIView subclass a
#import
- (void) setGradient {
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], (id)[[UIColor blackColor] CGColor], nil];
[self.view.layer insertSublayer:gradient atIndex:0];
}
Don't forget to add QuartzCore library to your project.