文本在UITextView框边界之外滚动
我有一个UITextView中有一些文字。 问题是文本在UITextView框的边界之外滚动。 (UITextView是不可编辑的。)
这里的代码和我试图解决这个问题:
- (void)viewDidLoad { textBG.contentInset = UIEdgeInsetsZero; // textBG.layer.masksToBounds = NO; textBG.layer.cornerRadius = 10.0; textBG.layer.borderWidth = 0.0; [textBG setClipsToBounds:YES]; [super viewDidLoad]; } - (void)textViewDidBeginEditing:(UITextView*)textView { textBG.contentInset = UIEdgeInsetsZero; [textBG setClipsToBounds:YES]; } - (void) shouldChangeTextInRange:(UITextView*)textView { textBG.contentInset = UIEdgeInsetsZero; [textBG setClipsToBounds:YES]; }
谢谢你的帮助
用textViewDidBeginEditing这样的textView委托方法写这个
textBG.contentInset = UIEdgeInsetsZero;
在viewDidload中
[textBG setClipsToBounds:YES];
尝试在XIB中更改您的TextView,如下所示: