//正在改变
- (void)textViewDidChange:(UITextView *)textView
{
NSLog(@"%@", textView.text);
//实时显示字数
self.strlength.text = [NSString stringWithFormat:@"%lu/120", (unsigned long)textView.text.length];
//字数限制操作
if (textView.text.length >= 120) {
textView.text = [textView.text substringToIndex:120];
self.strlength.text = @"120/120";
SHOW_ALERT(@"最多只能输入120字");
} else {
}
}
#pragma mark - lazy
- (TextViewPlaceHolder *)textView
{
if (!_textView) {
_textView = [[TextViewPlaceHolder alloc]init];
_textView.delegate = self;
_textView.placeholder = @"请发表您的评论...";
_textView.font = SFONT(ChangeSizeNOPlus(16));
}
return _textView;
}
- (UILabel *)strlength
{
if (!_strlength) {
_strlength = [[UILabel alloc]init];
_strlength.font = SFONT(ChangeSizeNOPlus(13));
_strlength.textColor = Text_Color;
_strlength.text = @"0/120";
}
return _strlength;
}
QQ20180511-164908-HD.gif
网友评论