UILabel文本颜色透明度和适当的图层阴影? [英] UILabel text color transparency with layer shadows in place?
问题描述
我有一个 UILabel
,我正在尝试向其应用半透明渐变作为颜色。例如,在我的 UILabel
子类中,我尝试通过以下方式设置渐变颜色:
I have a UILabel
to which I am attempting to apply a semi-transparent gradient as a color onto. For example, in my UILabel
subclass I'm trying to set the gradient color this way:
self.textColor = [UIColor colorWithPatternImage:someTransparentGradient];
尽管搞砸了,但我发现 UILabel
While messing around with this, however, I discovered that a UILabel
doesn't seem to be able to draw with transparency when layer shadows are in place. I attempted to set the text color to clear:
self.textColor = [UIColor clearColor];
但文本最终变成白色。
but the text ended up being white. Ideas?
如果您将文字颜色设置为清除,然后将层阴影应用于文本视图,则可以自己复制问题。
推荐答案
我通常不接受自己的答案,但是在这种情况下,我必须接受。这似乎是一个错误。每当将图层阴影应用于 UILabel
时,就不再支持文本透明性。我会提出雷达。
I don't normally accept my own answers, but in this case I must. This seems to be a bug. Whenever layer shadows are applied to a UILabel
, text transparency is no longer supported. I will file a radar.
这篇关于UILabel文本颜色透明度和适当的图层阴影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!