Simplest way to implement a "Read More" button to expand a UITextView in iOS Swift 2?

11,797

I would suggest you the ilyapuchka ReadMoreTextView library which is on this link. It is the easiest way to achieve this and it is retty lightweight.

You can install it with CocoaPods, just implement pod 'ReadMoreTextView' into the podfile and you can use it likie this:

let textView = ReadMoreTextView()

textView.text = "Lorem ipsum dolor ..."

textView.shouldTrim = true
textView.maximumNumberOfLines = 3
textView.trimText = "Read more"
Share:
11,797

Related videos on Youtube

user3755632
Author by

user3755632

Updated on October 09, 2022

Comments

  • user3755632
    user3755632 over 1 year

    I am looking to implement a "Read more" button that will expand the UITextView so that someone can read the whole text if they wish. I haven't managed to find an easy way to achieve this yet. I tried to "play" with the container's height but it doesn't give me the desired results. I would really appreciate any ideas.

  • user3755632
    user3755632 almost 8 years
    @TarvoMäesepp I just added a screenshot with the errors. Thanks for trying to help.
  • Tarvo Mäesepp
    Tarvo Mäesepp almost 8 years
    @UlliH, Sorry, I had long trip to Croatia, I can help you now. I think I need your whole project or you have to learn how to use Cocoapods. it is easy.