Add more button at the end of text inside UITextView Objective-C?

后端 未结 2 919
天涯浪人
天涯浪人 2021-01-22 17:48

I am trying to do something similar to the one in this link http://www.oracle.com/webfolder/ux/mobile/pattern/img/expand-collpase-description.png

Expanding the content i

相关标签:
2条回答
  • 2021-01-22 17:55

    I'm not sure exactly how Apple implements it, but I can almost guarantee that it isn't a subview of the UITextView. How I would implement this feature would be to set up a custom container view for the UITextView. Set the default height for the container, and then if the UITextView's height is greater than the container view's height, display a more UIButton in the buttom right (or left, or top right, or wherever you want, bottom left seems to make the most sense) that simply animates the height of the container view to fit the UITextView.

    If you really wanted to make it all in just a textview, I suppose you would have to subclass it to provide that kind of custom functionality, but someone else may know a way to do this all without subclassing UITextView. My approach would be the one described above.

    0 讨论(0)
  • 2021-01-22 18:08

    I'm doing the same thing. Just add the button to textView.superView, because textView is scrollView. Use button's rect in textView as
    textView.textContainer.exclusionPaths = [UIBezierPath(rect: rect)]

    At last, I did it. Most important thing is rect must be included in textView.frame.

    0 讨论(0)
提交回复
热议问题