我想根据文本长度增加 textview 高度我尝试了一些代码,但结果像第一张图片一样,但我想像第二张图片一样。
代码:
- (void)viewDidLoad {
[super viewDidLoad];
textview.text = @"This returns the size of the rectangle that fits the given string with the given font. Pass in a size with the desired width and a maximum height, and then you can look at the height returned to fit the text. There is a version that lets you specify line break mode also.This returns the size of the rectangle that fits the given string with the given font. Pass in a size with the desired width and a maximum height, and then you can look at the height returned to fit the text. There is a version that lets you specify line break mode yes.";
CGRect frame = textview.frame;
frame.size.height = textview.contentSize.height;
textview.frame = frame;
textview.ScrollEnabled = NO;
}
最佳答案
关于ios - 如何根据文本长度增加 TextView 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31336642/