I'm trying to add a 1px black drop shadow to a button label with no luck. I've tried this:self.setTitleShadowOffset = CGSizeMake(0, -1);
but I get:
Request for member 'setTitleShadowOffset' in something not a structure or union
Any suggestions would be fantastic thanks!
The other answers do not properly set the shadow color (I suspect they didn't notice because they were trying to set the shadow color to what it is by default, black.)
This code worked for me to add a white shadow to the text of my button:
The
setTitleShadowOffset
forUIButton
is deprecated. Use theshadowOffset
of titleLabel property ofUIButton
buttonName.titleLabel.shadowOffset = CGSizeMake(0, -1);
The right property is self.titleLabel.shadowOffset:
Here is how to add shadow to the button title in Objective-C with radius property:
In Swift 3.0
for Swift 3: