CAGradientLayer *colorLayer = [CAGradientLayer layer];
colorLayer.frame = (CGRect){CGPointZero,CGSizeMake(200, 200)};
colorLayer.position = self.view.center;
[self.view.layer addsublayer:colorLayer];
//颜色分配
colorLayer.colors = @[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor greenColor].CGColor, (__bridge id)[UIColor blueColor].CGColor];
//颜色分割线
colorLayer.locations = @[@(.25), @(.5), @(.75)];
//起始点
colorLayer.startPoint = CGPointMake(0, 0);
//结束点
colorLayer.endPoint = CGPointMake(1, 0);