iOS

渐变色设置

2016-11-24  本文已影响7人  cocoawork丶
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.view.frame;
//gradient.colors数组元素设置越多渐变就越细腻
gradient.colors = [NSMutableArray arrayWithObjects:
                       (id)[UIColor colorWithRed:0.916 green:0.856 blue:0.494 alpha:1.000].CGColor,
                       (id)[UIColor colorWithRed:1.000 green:0.971 blue:0.787 alpha:1.000].CGColor,
                       (id)[UIColor colorWithRed:0.883 green:0.903 blue:1.000 alpha:1.000].CGColor,
                       nil];
    
    //可以实现横向渐变色   对角方向渐变色
gradient.startPoint = CGPointMake(0, 0);
gradient.endPoint = CGPointMake(0, 1);
[self.view.layer insertSublayer:gradient atIndex:0];
上一篇下一篇

猜你喜欢

热点阅读