Good evening, tell me how you can get the height of the text in pixels, setting the desired width.
For example:
I have a STRING variable with contents: "The priest had a dog. He loved her. She ate a piece of meat. He killed her."
I need to create a TextView with a certain width, for example 800 wide, and I don’t know the height, because String variable can be 1000 words.
I need to calculate the height, to create a TextView, and place a variable in the text.
In Objective-C, I did it like this:
UIFont *cellFont = [UIFont systemFontOfSize:12]; CGSize constraintSize = CGSizeMake(self.view.frame.size.width-70, MAXFLOAT); CGSize labelSize = [STRING sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:NSLineBreakByWordWrapping]; return labelSize.height + 37.0f;
wrap_content? - Yuriy SPb ♦