9

We're currently building an iPhone app and would like the text to have a glowing effect to fit in with the realistic UI design.

Here is what we're trying to achieve.

glowing text

We are struggling to create the inner glow effect at the moment so any help would be appreciated.

In photoshop this text has

  • a color of #98c1c1
  • Outer glow: #ffffff, Screen blend mode, 30% opacity, 5px size.
  • Inner glow: #c79d85, Color Dodge blend mode, 70% opacity, 5px size.

Thanks, Mark.

markstewie
  • 9,237
  • 10
  • 50
  • 72
  • 1
    This possibly can help you: http://stackoverflow.com/questions/1420131/iphone-text-glow-effect or this http://www.redrobotstudios.com/blog/2010/04/29/create-glow-soft-shadow-text-on-iphone/ – TheZ Jun 28 '12 at 22:19
  • [This answer](https://stackoverflow.com/a/8482103/77567) should help you with the inner glow. – rob mayoff Feb 17 '19 at 09:23

2 Answers2

14

To set up the button with the text colored #98c1c1, use:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 60)];
label.textColor = [UIColor colorWithRed:((float)152/255) green:((float) 193/255) blue:((float) 193/255) alpha:1.0f];

I used Photoshop to find RGB components of #98c1c1, which ended up being R:152 G:193 B:193. And colorWithRed:green:blue:alpha: takes a normalized value between 0 and 1, and that's why I made it the RGB value over 255.

For the outer glow, use:

label.layer.shadowColor = [UIColor whiteColor].CGColor;
label.layer.shadowOffset = CGSizeMake(0.0, 0.0);    
label.layer.shadowRadius = 10.0;
label.layer.shadowOpacity = 0.3;
label.layer.masksToBounds = NO;

You want the opacity to be 30% and the shadow color #ffffff (white). That is why label.layer.shadowOpacity is set to 0.3 (30%) and label.layer.shadowColor is set to white.

I'm not quite sure about how to implement the inner glow, but you could possibly create a method that duplicates the text but makes the font smaller and centers the new text, to create the effect of an inner glow. Remember to import <Quartzcore/Quartzcore.h>!

pasawaya
  • 11,515
  • 7
  • 53
  • 92
0

Updating the code posted by pasawaya:

label.layer.shadowColor = ([UIColor .green] as! CGColor)
label.layer.shadowOffset = CGSize.zero
label.layer.shadowRadius = 10.0;
label.layer.shadowOpacity = 0.
label.layer.masksToBounds = false
CrazyOne
  • 605
  • 7
  • 13