title: Figure out size of UILabel based on String in Swift
body: <p>I am trying to calculate the height of a UILabel based on different String lengths.</p>
  
  <pre><code>func calculateContentHeight() -&gt; CGFloat{
      var maxLabelSize: CGSize = CGSizeMake(frame.size.width - 48, CGFloat(9999))
      var contentNSString = contentText as NSString
      var expectedLabelSize = contentNSString.boundingRectWithSize(maxLabelSize, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: [NSFontAttributeName: UIFont.systemFontOfSize(16.0)], context: nil)
      print("\(expectedLabelSize)")
      return expectedLabelSize.size.height
  
  }
  </code></pre>
  
  <p>Above is the current function I use to determine the height but it is not working. I would greatly appreciate any help I can get.  I would perfer the answer in Swift and not Objective C.</p>