Glowing Text with Core Graphics

I needed to draw “glowing text” in my iPhone app and I couldn’t find exactly what I needed but I did piece this bit of code together to create this results.

Pasted Graphic

Here is the code:

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGColorRef glowColor = CGColorCreateCopyWithAlpha([[UIColor blueColor] CGColor], 0.85f);

    [[UIColor whiteColor] set];
    CGContextSetShadowWithColor( context, CGSizeMake( 0.0, -1.0 ), 3.0f, glowColor );
    CGColorRelease(glowColor);

    NSString *text = [NSString stringWithString:@"Cool glowing text..1234 5678"];

    [text drawAtPoint:CGPointMake(25.0f, 0.5f) withFont:[UIFont fontWithName:@"Thonburi-Bold" size:22.0f]];

    CGColorRef shadowColor = CGColorCreateCopyWithAlpha([[UIColor blackColor] CGColor], 0.70f);
    CGContextSetShadowWithColor(context, CGSizeMake(0.0f, 1.0f), 0.0f, shadowColor);
    CGColorRelease(shadowColor);
[
    text drawAtPoint:CGPointMake(25.0f, 0.5f) withFont:[UIFont fontWithName:@"Thonburi-Bold" size:22.0f]];

}