Unable to get shadow of UILabel text of any color but gray

So I set UILabel.shadowColor to not gray, but the shadow always looks 50% opaque gray (or so). For example, I tried to set the shadow to red, and I still see gray. Has anyone else seen this? (This is a UILabel inside a custom navigation bar button)

+4
source share
2 answers

I ran into the same problem trying to add a non-gray shadow to the UIButton titleLabel . The solution is to set the properties of the layer button 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 necessary for the effect to appear at all, and shadowRadius must be set explicitly, since the default is 3.0 (very blurry).

This solution requires #import <QuartzCore/QuartzCore.h> .

+1
source

Are you sure you are not confusing backgroundColor with shadowColor?

0
source

All Articles