- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
//获取输入内容
NSString *textStr = [textView.text stringByReplacingCharactersInRange:range withString:text];
if (![textStr isEqualToString:@""]) {
self.addBtn.enabled = YES;
self.addBtn.backgroundColor = RGB(246, 28, 87);
} else {
self.addBtn.enabled = NO;
self.addBtn.backgroundColor = RGB(199, 199, 199);
}
//点击回车键隐藏键盘
if([text isEqualToString:@"\n"]) {
[textV resignFirstResponder];
return NO;
}
return YES;
}
网友评论