Drawing text in a UIView with iOS and Swift

You can usually rely on UI classes such as UILabel to render text on a view. Sometimes however, you need to render text using the drawRect function of the UIView class. In the following example, we take an NSString, set some attributes and draw the text inside of a rectangle