CAGradientLayer *newShadow = [[CAGradientLayer alloc] init];
//添加渐变的颜色组合
newShadow.colors = [NSArray arrayWithObjects:
(id)[[[UIColor colorWithRed:236./255. green:240./255. blue:241./255. alpha:1.0] colorWithAlphaComponent:1.0f] CGColor],
(id)[[[UIColor colorWithRed:236./255. green:240./255. blue:241./255. alpha:1.0] colorWithAlphaComponent:0.0f] CGColor],
nil];
newShadow.colors = [NSArray arrayWithObjects:
(id)[[[UIColor colorWithRed:236./255. green:240./255. blue:241./255. alpha:1.0] colorWithAlphaComponent:1.0f] CGColor],
(id)[[[UIColor clearColor] colorWithAlphaComponent:0.0f] CGColor],
nil];
如果只是指定clearColor,无法判断渐变的RGB value,达不到预想颜色。
而指定相同rgb,不同透明度,则可以保证rgb不变,只改变透明度渐变。