首页 > 其他 > 详细

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

时间:2015-11-25 13:03:53      阅读:331      评论:0      收藏:0      [点我收藏+]
- (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 = @"";
    }
    
}

  

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

原文:http://www.cnblogs.com/yqlog/p/4994177.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!