title: Swift 4 in Xcode 9 - How to use boundingrect in NSAttributedstring?
body: <p>I want to get the length of some texts in UILabel, and change the width property of UILabel dynamically.</p>
  
  <p>But I have no idea about how to set the parameters in the function boundingrect.
  This is the documentation of Apple Developer.</p>
  
  <pre><code>func boundingRect(with size: CGSize, 
        options: NSStringDrawingOptions = [], 
        context: NSStringDrawingContext?) -&gt; CGRect
  </code></pre>
  
  <p>,and I tried like this</p>
  
  <pre><code>let attr = NSMutableAttributedString(string: "test test test test , this is test text. test test test test , this is test text. test test test test , this is test text. ")
  //attr.addattributes
  print(attr.boundingrect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: 0), option: .truncatesLastVisibleLine
  ,context: nil)!)
  </code></pre>
  
  <p>But finally I got false width in print,so why and how to get the correct one.</p>