我有一个 CAGradientLayer 插入到这个在应用程序底部弹出的小细节 View 的底部。如您所见,我已将颜色从白色设置为透明,但出现了这种奇怪的灰色调。有什么想法吗?
// Set up detail view frame and gradient
[self.detailView setFrame:CGRectMake(0, 568, 320, 55)];
CAGradientLayer *layer = [CAGradientLayer layer];
layer.frame = self.detailView.bounds;
layer.colors = [NSArray arrayWithObjects:(id)[UIColor whiteColor].CGColor, (id)[UIColor clearColor].CGColor, nil];
layer.startPoint = CGPointMake(1.0f, 0.7f);
layer.endPoint = CGPointMake(1.0f, 0.0f);
[self.detailView.layer insertSublayer:layer atIndex:0];
这是有问题的 View :
最佳答案
clearColor 有一个 alpha 为 0 的黑色 channel ,所以我不得不使用
[UIColor colorWithWhite:1 alpha:0]
而且效果很好。
关于iOS白色到透明渐变层为灰色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24882361/