Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPhone Text Glow Effect

In my IPhone application, I want the text in UILabel to glow for a second, then fade for a sec;. Also i want to repeat this cycle for say 3 or 4 times.

Is this possible?

like image 282
Ramkumar KS Avatar asked Sep 14 '09 07:09

Ramkumar KS


2 Answers

As of 3.2 you there is direct support for shadows in the SDK.

label.layer.shadowColor = [label.textColor CGColor];
label.layer.shadowOffset = CGSizeMake(0.0, 0.0);

Play with the parameters:

label.layer.shadowRadius = 3.0;
label.layer.shadowOpacity = 0.5;

And to avoid shadow being clipped by the label bouds:

label.layer.masksToBounds = NO;

Don't forget to

#include <Quartzcore/Quartzcore.h>

and link against the QuartzCore or CoreGraphics frameworks (thanks to commenters for pointing this out).

like image 106
IlDan Avatar answered Oct 04 '22 19:10

IlDan


I've posted some sample code which subclasses UILabel and enables you to apply glow and soft shadows to text.

http://www.redrobotstudios.com/blog/2010/04/29/create-glow-soft-shadow-text-on-iphone/

like image 29
andrewgleave Avatar answered Oct 04 '22 19:10

andrewgleave