本文介绍了iOS 白色到透明渐变层为灰色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CAGradientLayer 插入到这个在应用程序底部弹出的小细节视图的底部.如您所见,我已将颜色从白色设置为透明,但出现了这种奇怪的灰色调.有什么想法吗?

I have a CAGradientLayer inserted to the bottom of this small detail view that pops up at the bottom of the app. As you can see, I've set the colors from white to clear, but there's this strange gray tint that is showing up. Any ideas?

    // 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];

这是有问题的观点:

推荐答案

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

clearColor has a black color channel with an alpha of 0, so I had to use

[UIColor colorWithWhite:1 alpha:0]

它工作正常.

这篇关于iOS 白色到透明渐变层为灰色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 04:07
查看更多