uitextField多行,uitextview 实现placeholder

UITextFiled不能多行,UITextView没有placeholder属性,我们就给它添加一个,遵守UITextView的代理方法

1. UITextView.text = @"placeholder";

2.

- (void)textViewDidBeginEditing:(UITextView*)textView {

if([textView.textisEqualToString:@"placeholder"]) {

textView.text=@"";

textView.textColor= [UIColorblackColor];

}

}

3.

- (void)textViewDidEndEditing:(UITextView*)textView {

if(textView.text.length<1) {

textView.text=@"placeholder";

textView.textColor= [UIColorlightGrayColor];

}

}

你可能感兴趣的:(uitextField多行,uitextview 实现placeholder)