简体   繁体   中英

size of the NSString to fit on UItextview

i want to find the size of NSString to display on UITextview. It is working good for English. But if the string is other languages like spanish, hindi, japanese means it is working slow:

CGSize ContentSize=[MainContentString sizeWithFont:TextView.font constrainedToSize:CSize lineBreakMode:UILineBreakModeWordWrap];

Is there a way to do it faster?

There is actually a very easy way to do resizing of the UITextView to its correct height of the content. It can be done using the UITextView contentSize.

CGRect frame = _textView.frame;
frame.size.height = _textView.contentSize.height;
_textView.frame = frame;

Check out UIView's autoresizesSubviews and contentMode - play with them in the storyboard.

Try it both with and without your implementation - see if it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM