Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outline for UILabel text

How do I add a black outline to my white UILabel text?

like image 545
hgpl Avatar asked Feb 22 '12 09:02

hgpl


2 Answers

One option is to set the shadow, which might not be exactly what you want, but achieves a similar effect. You can manually adjust the offset:

UILabel *myLabel = ...;
lbl.shadowColor = [UIColor whiteColor];
lbl.shadowOffset = CGSizeMake(0, -1.0);

Please note that you can also define this in Interface Builder for your UILabel.

shadow http://i.minus.com/jbiG0jVdOxJbgh.png

If this is not enough for you check out this blog post which deals with subclassing UILabel to get a glow effect:

glow
(source: redrobotstudios.com)

like image 79
Besi Avatar answered Oct 16 '22 05:10

Besi


Disclosure: I'm the developer of THLabel.

I've released a UILabel subclass a while ago, which allows an outline in text and other effects. You can find it here: https://github.com/tobihagemann/THLabel

I'm using Core Text and Core Graphics to achieve the effect.

like image 5
tobihagemann Avatar answered Oct 16 '22 05:10

tobihagemann