ios 渐变色

UIView *view = [[UIView alloc] init];
view.frame = CGRectMake(587,60,71,19.5);
view.backgroundColor = [UIColor colorWithRed:74/255.0 green:83/255.0 blue:90/255.0 alpha:1];

CAGradientLayer *gl = [CAGradientLayer layer];
gl.frame = CGRectMake(587,60,71,19.5);
gl.startPoint = CGPointMake(0, 0);
gl.endPoint = CGPointMake(1, 1);
gl.colors = @[(__bridge id)[UIColor colorWithRed:253/255.0 green:226/255.0 blue:41/255.0 alpha:1].CGColor,(__bridge id)[UIColor colorWithRed:255/255.0 green:166/255.0 blue:38/255.0 alpha:1].CGColor];
gl.locations = @[@(0.0),@(1.0)];

[self.view.layer addSublayer:gl];
view.layer.cornerRadius = 9.8;

猜你喜欢

转载自blog.csdn.net/a787188834/article/details/83038236