UITextFiled不能多行,UITextView沒(méi)有placeholder屬性,我們UITextView改成類(lèi)似有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];
}
}