iOS白色到透明渐变层为灰色

标签 ios iphone uiview calayer cagradientlayer

我有一个 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 :

Here is the problematic view

最佳答案

clearColor 有一个 alpha 为 0 的黑色 channel ,所以我不得不使用

[UIColor colorWithWhite:1 alpha:0]

而且效果很好。

关于iOS白色到透明渐变层为灰色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24882361/

相关文章:

ios - xcode 4.5 和 UIScrollview 有什么问题?

ios - OpenGL ES 可点击对象

ios - "This item cannot be shared. Please select a different item."WhatsApp iOS 共享扩展失败消息

iphone - 在 iPhone 上嵌入 YouTube 视频时出现问题

ios - 在大型 UIView 上绘制占用大量内存

ios - 需要在 UITableView 中创建不同的部分

ios - 使用 Swift 将顶部和底部填充添加到 UILabel

iphone - iPhone OS版本AppStore部署

uiview - 在 UIView 布局中,什么是 "update cycle"?

ios - 获取另一个 UIView 下的 UIView