Outline for UILabel text

I am sure this code will solve your problem.

In KSLabel.m class see this line of code

// Outline color
self.textColor = [UIColor whiteColor];

change it to

self.textColor = [UIColor blackColor];

and you will see the black border of the text.


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)


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.


For iOS5, the usual way is to use CoreGraphics to set fill/stroke and then render the graphics. It can be pretty tricky to get the alignment correct for all font sizes though.

I recommend looking at my solution here. You can either use it straight (it has diffuse shadows as well), or simply pick out the code that does the outline. For iOS6 there is a neater (smaller) solution which works even better. Look here.