颜色渐变Demo
- (void)viewDidLoad {
[super viewDidLoad];
//颜色渐变
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = CGRectMake(20, 100, 300, 400);
NSArray *colors = @[
(id)[UIColor cyanColor].CGColor,
(id)[UIColor colorWithRed:0.170 green:0.752 blue:1.000 alpha:1.000].CGColor,
(id)[UIColor colorWithRed:0.211 green:0.332 blue:1.000 alpha:1.000].CGColor
];
gradient.colors = colors;
gradient.startPoint=CGPointMake(0, 0);
gradient.endPoint=CGPointMake(1, 1);
[self.view.layer insertSublayer:gradient atIndex:0];
}
效果图如下:
|