Calculate height of multi-line UILabel

    func heightForLabel(#fontSize: CGFloat, labelWidth: CGFloat) -> CGFloat {
        let label:UILabel = UILabel(frame: CGRectMake(0, 0, labelWidth, CGFloat.max))
        label.numberOfLines = 0
        label.lineBreakMode = NSLineBreakMode.ByWordWrapping
        label.font = UIFont(name: "HelveticaNeue", size: fontSize)
        label.text = self
        return label.frame.height
To make a custom UILabel with correct height automatically:
```swift class YourLabel: UILabel { required init(coder decoder: NSCoder) { super.init(coder: decoder) }
init(text: String, fontSize: CGFloat, frame: CGRect){
    super.init(frame: CGRectMake(frame.origin.x, frame.origin.y, frame.width, text.heightForLabel(fontSize: fontSize, labelWidth: frame.width)))
    self.numberOfLines = 0
    self.lineBreakMode = NSLineBreakMode.ByWordWrapping
    self.font = UIFont(name: "HelveticaNeue", size: fontSize)
    self.text = text


<div>Then you will be able to use it like:</div>
YourLabel(text: "Label Name", fontSize: 12.0, frame: CGRectMake(0, 0, 100, 0)) 
// The height value in the frame won't be used and can be any value