title: Simulating UILabel behaviour on OSX
body: <p>I want to simulate the multi-line UILabel behaviour in an OSX application. 
  Drawing a multiline Label you can specify the number of rows and the linebreak system works great! </p>
  
  <p>Here an example of what I want to achieve. </p>
  
  <p>This is the string that I want to show with a UILabel </p>
  
  <pre><code>Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
  </code></pre>
  
  <p>I can select a <strong>3 lines</strong> label with tail truncation obtaining: </p>
  
  <pre><code> Lorem Ipsum is simply 
   dummy text of the 
   printing and typeset...
  </code></pre>
  
  <p>or with a 2 lines label with tail truncation i get:</p>
  
  <pre><code> Lorem Ipsum is simply 
   dummy text of the pri... 
  </code></pre>
  
  <p>I suppose that I need a low level API to draw a string in that way.</p>
  
  <p>Currently I find 3 different ways to draw text and I want to understand which is the right one to accomplish this task.</p>
  
  <hr>
  
  <p><strong>Cocoa Text</strong> </p>
  
  <p>NSTextView and NSTextField: It seems to be a too high level... I can't reproduce this effect (The NSTextView doesn't let me choose the number of rows, and the line break seems to transform the multi line NSTextView in a single line NSTextView).</p>
  
  <p><em><strong>Edit</em></strong>
  I thought to get the frame from a string, then get the lines from the frame and rebuild the frame using only the needed lines. What do you think?</p>
  
  <hr>
  
  <p><strong>Core Text</strong></p>
  
  <p>I have great control of the text drawing using frames, but... I can't find a way to define how many rows to display and how to truncate the string. </p>
  
  <hr>
  
  <p><strong>NSLayoutManager</strong> </p>
  
  <p>It seems to be a good solution too, but I don't know how to reproduce the UILabel multiline effect. </p>
  
  <p>Do you have some suggestions to help me in this tricky task? </p>