从stackoverflow找到的一个非常不错的textView的placeholder设定,不需要自定义直接设定
核心代码 :
说明:- (BOOL)textViewShouldBeginEditing:(UITextView *)textView { if ([[textView text] isEqualToString:PLACE_HOLDER_TEXT]) {//PLACE_HOLDER_TEXT是一个nsstring的宏 textView.text = @""; textView.textColor = [UIColor blackColor]; } return YES; } -(BOOL)textViewShouldEndEditing:(UITextView *)textView { if ([[textView text] length] == 0) { textView.text = PLACE_HOLDER_TEXT; textView.textColor = [UIColor lightGrayColor]; } return YES; }