title: Calculating attributed string height
body: <p>I'm trying to set a tableViewCell height equal to the height of the <code>attributedString</code> inside the cell. However whatever I do it does not seem to have the correctSize. this is what I've tried so far</p>
  
  <p><strong>cellHeight</strong></p>
  
  <pre><code>//Convert description to NSAttributedString and get height
  //width is equal to screen width - right and left offset
  //at the end add the bottom and height offset to the cell height
  return detailPetViewModel!.description
                  .lineSpacing(spacing: 4)
                  .heightWithConstrainedWidth(width: Sizes.screenWidth - 40) + 10
  </code></pre>
  
  <p><strong>Customize descLabel in cell subclass</strong></p>
  
  <pre><code>//Customize descLabel
  descLabel.font = FontFamily.Avenir.Regular.font(size: 16)
  descLabel.textColor = UIColor(named: .SecondaryTextColor)
  
  //Multiple lines
  descLabel.numberOfLines = 0
  descLabel.lineBreakMode = .byWordWrapping
  descLabel.sizeToFit()
  </code></pre>
  
  <p><strong>linespacing extension</strong></p>
  
  <pre><code>extension String {
      func lineSpacing(spacing: CGFloat) -&gt; NSAttributedString {
  
          let paragraphStyle = NSMutableParagraphStyle()
          paragraphStyle.lineSpacing = spacing
  
          let attributedString = NSMutableAttributedString(string: self)
          attributedString.addAttribute(NSParagraphStyleAttributeName, value:paragraphStyle, range:NSMakeRange(0, attributedString.length))
          return attributedString
      }
  }
  </code></pre>
  
  <p><strong>height Extension</strong></p>
  
  <pre><code>extension NSAttributedString {
      func heightWithConstrainedWidth(width: CGFloat) -&gt; CGFloat {
          let constraintRect = CGSize(width: width, height: .greatestFiniteMagnitude)
          let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, context: nil)
  
          return boundingBox.height
      }
  
  }
  </code></pre>