StyleLabel: adding styles to a UILabel
As iOS development is evolving (or maturing) designers are getting more demanding, trying to match the complexity of their designs to what they do for the web. Though this is fine with static designs, it usually becomes a problem with text which in most cases needs to be dynamic. On one hand that’s fine since new OS versions enabled enhancements like easy integration of new non-standard fonts and soft shadow on CALayers. On the other hand some features like gradient text do not come out-of-the-box yet for us.
StyleLabel is one approach in overcoming some of the headaches designers might give you. StyleLabel (which at the moment should be called VerticalGradientLabel really) draws text with a vertical gradient of the colors specified. It also optionally adds a stroke around the text and a soft shadow with all parameters easily customizable through it’s few properties.
The result looks like this without the stroke. The way the gradient is set, the UILabel doesn’t lose any of it’s properties so it can still render unicode text (an issue with some other approaches out there) etc.
Please note that this class is far from being finished. As usual contributions and feedback are welcome.