Autoexpand UITextView height dynamically in ios

后端 未结 4 1131
醉话见心
醉话见心 2021-01-17 00:03

I have a simple textView who\'s data gets populated dynamically. I want to resize the height of the textview once the data is populated so that I don\'t see a vertical scrol

4条回答
  •  梦谈多话
    2021-01-17 00:52

    This depends on font size. Following code retrieve the font size of text and return the height and width required. This may help you to create the logic:

    NSDictionary *attribs1 = @{
                              NSFontAttributeName: tViewhobbies.font
                              };
    
    CGSize textViewSize = [tViewhobbies.text sizeWithAttributes:attribs1];
    

提交回复
热议问题