So I'm setting UILabel.shadowColor to a non-gray color, but the shadow always appears as opaque 50% gray (or so). For example, I tried setting the shadow to red and I still see gray. Has anyone else seen this? (This is the UILabel inside a custom nav bar back button)
I ran into this same problem while trying to add a non-gray drop shadow to a UIButton
's titleLabel
. The solution appears to be to set the properties of the button's layer
instead:
button.titleLabel.layer.shadowColor = [UIColor whiteColor].CGColor;
button.titleLabel.layer.shadowOffset = CGSizeMake(0, 1);
button.titleLabel.layer.shadowOpacity = 1;
button.titleLabel.layer.shadowRadius = 0;
shadowOpacity
is necessary for the effect to appear at all, and shadowRadius
has to be set explicitly since the default is 3.0 (very blurry).
This solution requires #import <QuartzCore/QuartzCore.h>
.
你确定你没有将backgroundColor与shadowColor混淆吗?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.