简单的记录一下
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self createUI];
}
// 创建界面
- (void)createUI
{
CAGradientLayer *layer = [CAGradientLayer layer];
layer.frame = CGRectMake(100, 100, 100, 100);
// 进行颜色分配
UIColor *green = [UIColor greenColor];
UIColor *yellow = [UIColor yellowColor];
UIColor *red = [UIColor redColor];
layer.colors = @[(__bridge id)green.CGColor,(__bridge id)yellow.CGColor,(__bridge id)red.CGColor];
// 设置颜色分割线
layer.locations = @[@(0.25),@(0.5),@(0.75)];
// 设置起始点
layer.startPoint = CGPointMake(0, 0);
layer.endPoint = CGPointMake(1, 0);
[self.view.layer addSublayer:layer];
}
盗个图.png
盗个图.png
网友评论