cqrjgg
Last Updated: August 24, 2018
·
5.993K
· _jeffreyjackson

UILabel text glow

UILabel needs a little something to make it pop.

UIColor *glowColor = [UIColor greenColor];
textLabel.layer.shadowColor = [glowColor CGColor];
textLabel.layer.shadowRadius = 3.0f;
textLabel.layer.shadowOpacity = .8;
textLabel.layer.shadowOffset = CGSizeZero;
textLabel.layer.masksToBounds = NO;

You might not want to use green, but you get the idea.

1 Response
Add your response

30468

To apply a glow to the actual text in a label, you have to override drawTextInRect on the label itself. You're setting https://showbox.software/a shadow on the label's layer, which is a rectangle.https://dltutuapp.com/
https://9apps.ooo/
The override is quite simple. You just adjust the graphics context, call super, then restore the graphics context:

-(void)drawTextInRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);

CGContextSetShadowWithColor(context, CGSizeZero, 30.0, [UIColor blueColor].CGColor);

[super drawTextInRect:rect];

CGContextRestoreGState(context);
3 months ago ·