When developing on iOS, I am a big fan of CoreAnimation, and particularly the CALayer and its subclasses; they're lighter in weight than UIView, carrying less baggage, and are a quick way to display all sorts of elements in a user interface.
CALayer has a number of useful subclasses, among them CATextLayer, which displays text in an arbitrary font and size* within its bounds. One shortcoming of CATextLayer, however, is that it does not provide any means of measuring the dimensions of its contents, requiring you to guesstimate them and size the layer to fit, or else pre-measure the string before sizing your layer. This is complicated somewhat by the fact that CATextLayer can accept font settings in several forms (string font name, CoreText CTFont or CoreGraphics CGFont), none of which are the convenient UIFont object.
Having had reason to create a precisely-sized CATextLayer recently, I looked into the issue and have written a small category extending CATextLayer, adding a method for setting its bounds to neatly encompass its text.[...]