您應該使用這裏的答案:UITextView animating change of frame does not animate text reallocation
在textviews文本不會總是按照預期行事。爲此,您必須設置一個NSTimer並在每個打勾上設置框架大小。 這樣做:
textview.frame = CGRectMake (textview.frame.origin.x, textview.frame.origin.y, textview.frame.size.width-1, textview.frame.size.height-1);
然後當它這樣做我會完全從上海華刪除的TextView並將其設置爲無,然後初始化一個新的。原因是當出於某種原因在文本框中添加了填充時,更改了textviews的框架。你不會注意到它,除非你改變框架可能至少100次。
[textview removeFromSuperview];
textview = nil;
textview = [[UITextView alloc] initWithFrame:CGRectMake(x, y, width, height)];
textview.text = yourTextString;
//You will also have to set whatever non default properties you want, such as text or background color
[view addSubview:textview];