UITextFiled不能多行,UITextView没有placeholder属性,我们UITextView改成类似有placeholder效果,遵守UITextView的代理方法<UITextViewDelegate>
UITextView.text = @"placeholder";
- (void)textViewDidBeginEditing:(UITextView*)textView {
if([textView.textisEqualToString:@"placeholder"]) {
textView.text=@"";
textView.textColor= [UIColor blackColor];
}
}
- (void)textViewDidEndEditing:(UITextView*)textView {
if(textView.text.length<1) {
textView.text=@"placeholder";
textView.textColor= [UIColor GrayColor];
}
}
网友评论