Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wy19901227 opened this issue Aug 21, 2015 · 1 comment
Open

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

wy19901227 opened this issue Aug 21, 2015 · 1 comment

Comments

@wy19901227
Copy link

一般有了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];
}

}

@burning-git
Copy link
Owner

好的。。。。感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants