I know soft shadows are not supported by the UILabel out of the box, on the iPhone. So what would be the best way to implement my own one?
EDIT:
Obviously I will subclass the UILabel
and draw in the -drawRect: My question is, how do I get the contents of the label as graphics and draw around them, blur them etc...
EDIT 2:
I returned to this question about a year later. In the meantime I've built a class that allows you to easily add soft shadow to a label and tweak it's radius etc and also to draw gradients on the text itself. You can find it on GitHub: https://github.com/doukasd/iOS-Components/tree/master/Views
Select the text or WordArt that you want to format. On the Format tab, under Text Styles, click Effects, point to Shadow, and then click the shadow style that you want.
Basic Swift Code for iOS Apps This will not only makes the text attractive but also it will also enhance the user experience. Here we will see how we can add shadow on text. Step 2 − Add label in Main. storyboard and create @IBOutlet of the label and name it lblHelloWorld.
To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.
As of 3.2 there is direct support for shadows in the SDK.
label.layer.shadowColor = [label.textColor CGColor]; label.layer.shadowOffset = CGSizeMake(0.0, 0.0);
#import <QuartzCore/QuartzCore.h>
and play with some parameters:
label.layer.shadowRadius = 3.0; label.layer.shadowOpacity = 0.5;
And, if you find your shadow clipped by the label bounds:
label.layer.masksToBounds = NO;
finally set
label.layer.shouldRasterize = YES;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With