iOS CAGradientLayer 颜色渐变

 1   CAGradientLayer *layer = [CAGradientLayer layer];
 2     layer.startPoint = (CGPoint){0.5f, 0.0f};
 3     layer.endPoint = (CGPoint){0.5f, 1.0f};
 4     layer.colors = @[(id)[UIColor purpleColor].CGColor,
 5                      (id)[UIColor cyanColor].CGColor,
 6                      (id)[UIColor magentaColor].CGColor,
 7                      (id)[UIColor redColor].CGColor];
 8     layer.locations = @[@0.0f, @0.6f, @1.0f];
 9     layer.frame = self.view.layer.bounds;
10     [self.view.layer insertSublayer:layer atIndex:0];

 

posted on 2015-06-23 17:14  airy99  阅读(179)  评论(0编辑  收藏  举报