您的位置:首页 > 产品设计 > UI/UE

UITextView的字数限制 及 添加自定义PlaceHolder

2015-11-25 11:44 465 查看
- (void)textViewDidChange:(UITextView *)textView{
NSString *temp=textView.text;
//字数超过限制数量时,进行截取替换
if([[textView text] length] > _limitCharactorNumbers){
textView.text=[temp substringToIndex:_limitCharactorNumbers];
}
//显示剩余字数
_leftNumberLabel.text = [NSString stringWithFormat:@"%u",(_limitCharactorNumbers - textView.text.length)];

// placeHolder实现方法: 自己添加一个UILabel在UITextView左上角
if (textView.text.length == 0) {
_placeHolderLabel.text = _placeHolder;
}else{
_placeHolderLabel.text = @"";
}

}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: