title: How to calculate the height of a UILabel?
body: <p>I'm trying to set the UITableViewCell's Height depending on the height of a UILabel.<br>
  My problem is similar to <a href="https://stackoverflow.com/questions/5682208/set-uitableviewcells-height-depending-on-the-height-of-a-uilabel">this one</a>.<br>
  But the OC code in that answer seems to been deprecated now(I'm not sure, just can't find it).<br>
  I'm using the following code to calculate the height of the label. </p>
  
  <pre><code>extension String {
      // the length of text in one line
      func size(ofFont font: UIFont) {
          return (self as NSString).size(attributes: [NSFontAttributeName: font])
  }
  </code></pre>
  
  <p>In <code>cellForRow:</code> method:</p>
  
  <pre><code>let size = text.size(ofFont: font)
  let height = ceil(size.width/(UIScreen.main.bounds.width))*size.height
  </code></pre>
  
  <p>But it would be additional break line if the last word is too long to display in one line.<br>
   So, here comes the bug.<br>
  Thank you for any suggestion.</p>