TextViewPlaceholder
TextViewPlaceholder copied to clipboard
自定义TextView,可根据内容来 是否显示 Placeholder,可自定义Placeholder的文字颜色、大小.
BUG
iOS9.2、 iPhone5C/ 首次显示时placeholdLabel不显示,打印frame为5、7、0、0 输入文字后再删除,正常显示 layoutSubviews中给的frame正常, 不知道为什么
一般有了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) {...