美文网首页
CAGradientLayer

CAGradientLayer

作者: 陈世美_ | 来源:发表于2015-06-18 10:32 被阅读132次

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);

相关文章

网友评论

      本文标题:CAGradientLayer

      本文链接:https://www.haomeiwen.com/subject/lgdsqttx.html