I am releasing a UILabel subclass, which allows shadow blur, stroke text and fill gradient. You can find it here: tobihagemann/THLabel
I know that there are already classes out there like OHAttributedLabel, FXLabel and KSLabel, but none of them fulfilled all my needs for my game. My motivation was:
- I needed an outer stroke, which seems to be kind of special, because Core Graphics only can centered stroke. I found the neat solution in KSLabel, which doubles the stroke size and draws the text just over it again, which cuts the stroke into halves.
- The stroke manipulates the character glyph widths, which has to be dealt with in all style operations. I came up with the idea of using invisible strokes, which works perfectly.
- Shadow has to be also thrown off by the stroke, not the text only!
Thanks to Kai Schweiger for making KSLabel, which started my own implementation, and Nick Lockwood for making FXLabel, which is just insanely great, and I adapted most of his framework.
I had to reorganize the drawRect:
method several times, which caused me a lot of headache. For learning purposes I built the class from ground up, that’s why I didn’t just enhance FXLabel for example.
If you find any bugs or want to give feedback, I’m happy to hear them!