title: Read/see More at the end of the label
body: <p>I am trying to create a read more button at the end of my label. I want it to display 3 lines by default. I am coding in swift not objective c. Only when the user clicks the read more part of the label, should the label expand. It should look and work exactly like it does on instagram except on Instagram, it is in a tableview cell. My label and read more button will be in a scrollview. I have managed to get the expanding and contracting part working by adjusting the number of lines property of the label. </p>
  
  <pre><code>if descriptionLabel.numberOfLines == 0{
      descriptionLabel.numberOfLines = 3
  }else {
      descriptionLabel.numberOfLines = 0
  }
  descriptionLabel.lineBreakMode = NSLineBreakMode.byWordWrapping
  </code></pre>
  
  <p>I am having problems with putting a "...more" at the end of the label and cutting the text off at the right place. I have looked at other people's responses to similar questions but nothing seems to work properly. </p>
  
  <p>I can put a button over the last line of text so making the see more part of the label clickable also isn't the problem. The problem I am having is truncating the text at the right place and placing the see more text at the right place so that it displays. </p>
  
  <p>I also want the read more button to only appear when it is necessary. I don't want to it appear when there are only 1-3 lines of text. This is also something I am having issues with. </p>
  
  <p>I can't use this <a href="https://github.com/apploft/ExpandableLabel" rel="nofollow noreferrer">https://github.com/apploft/ExpandableLabel</a> because it does not support scrollviews just tableviews. </p>
  
  <p>the swift solution here didn't work: <a href="https://stackoverflow.com/questions/32309247/add-read-more-to-the-end-of-uilabel">Add &quot;...Read More&quot; to the end of UILabel</a>. It crashed the app. </p>
  
  <p>Finally, the read more button should be in line with the last line of text and at the end of it. It would be an added benefit it this worked in a tableview cell as well!</p>