String length with given font to fit UITextView

后端 未结 4 728
遇见更好的自我
遇见更好的自我 2021-01-01 00:17

I need to move text that the user has entered into a large multi-line UITextView into a smaller (but still multi-line) UITextView*. If the user has

4条回答
  •  春和景丽
    2021-01-01 01:08

    I think Jonathan was on to something about the UILabel...

    So, the user finishes editing the UITextView, you get the string of text and pass it to the UILabel. You change the alpha of the UITextView to 0 and/or remove it from superview. Possibly store the untruncated full text in an ivar.

    UILabels are not "editable", however you can detect a touch with a UILabel (or it's superview). When you detect the touch on the UILabel, you simply restore the hidden UITextView and restore the string you saved.

    Sometimes the SDK is a pain, but it almost always wins the fight. Many times, it is better to adjust your design to UIKit conventions

提交回复
热议问题