Two columns of text in a UITextView?

Is it possible to organize the text in two columns using only a UITextView? If not, how can I calculate the height for a given line of text?

+3
source share
2 answers

NSString has metric features like

sizeWithFont:forWidth:lineBreakMode:

which you will need to use. In fact, I usually use sizeWithFont:constrainedToSize:lineBreakMode:after creation CGSizeMake(columnWidth, FLT_MAX), which is then used for the result as well - with FLT_MAX as the height, only the width is limited. The resulting CGSize will return you the actual height.

I think that with this in mind, it will be much easier for you to use two UITextViewsand break the text into two sections.

+1
source

UITextView . , UITextView, - :

myTextView.text = theText;
theTextHeight = [myTextView contentSize].height; // in points
-1

Source: https://habr.com/ru/post/1790140/


All Articles