TextViewPlaceholder icon indicating copy to clipboard operation
TextViewPlaceholder copied to clipboard

你好,有个字数限制的需求需要增加。

Open wy19901227 opened this issue 10 years ago • 1 comments

一般有了placeholder的需求,往往也有个最多字符的需求,经过一番研究,也算解决了这个需求,代码贴出来,让这个类跟好点 -(void)DidChange:(NSNotification*)noti{

if (self.placeholder.length == 0 || [self.placeholder isEqualToString:@""]) {
    _PlaceholderLabel.hidden=YES;
}

if (self.text.length > 0) {
    _PlaceholderLabel.hidden=YES;
}
else{
    _PlaceholderLabel.hidden=NO;
}


if (_eventBlock && self.text.length > self.maxTextLength) {

    void (^limint)(BRPlaceholderTextView*text) =_eventBlock;

    limint(self);
}
//解决限制字符的问题
if (!self.markedTextRange&&self.text.length>self.maxTextLength) {
    self.text=[self.text substringToIndex:self.maxTextLength];
}

}

wy19901227 avatar Aug 21 '15 09:08 wy19901227

好的。。。。感谢

burning-git avatar Aug 21 '15 16:08 burning-git