Is there an easy way or library available to let text glow?

I’d like to make a glowing text that looks like if it was shining or emmitting light. Actually this would be done with some blurryness in the background. But I’ve found nothing in the iPhone SDK that would do it.

3 Solutions

You can do this using pure Quartz drawing. Within -drawRect: for a UIView or -renderInContext: for a CALayer, the following code will draw text and apply a glow around it:

CGContextSetShadowWithColor( context, CGSizeMake( 0.0, 0.0 ), 20.0f, glowColor );   

[text drawAtPoint:CGPointMake(0.5f, 0.5f) withFont:[UIFont fontWithName:@"Helvetica" size:16.0f]];

where text is an NSString, and glowColor is a CGColorRef for the glow you want to apply. This example will draw a glow that extends out 20 pixels from the 16-point Helvetica text, and is centered on the text.

You can easily convert this into a shadow by providing a different displacement (second argument in the first function) and by using a black CGColor for the shadow.


How about rendering the text into an initially transparent buffer using the desired glow colour, then apply a blur to it, and then render the text again over the top in the desired text colour.

Then you can draw the buffer wherever it needs to be.

See also the answers to “How do I create blurred text in an iPhone view?” which would suggest Cocoa Touch lacks any built in blur filters. You can write your own of course.


I created a simple iOS4 project based on answer above from Bard Larson and Cocoanetics on my blog, click here for further info and project source