Skip to content

Instantly share code, notes, and snippets.

@syxc
Forked from jagbolanos/gist:2649319
Created December 17, 2012 06:37
Show Gist options
  • Select an option

  • Save syxc/4316230 to your computer and use it in GitHub Desktop.

Select an option

Save syxc/4316230 to your computer and use it in GitHub Desktop.
- (void) viewDidLoad {
//...
comments.text = @"Comments";
comments.textColor = [UIColor lightGrayColor];
isEmpty = YES;
//...
}
- (BOOL)textViewShouldBeginEditing:(UITextView*)textView {
if (isEmpty) {
comments.text = @"";
comments.textColor = [UIColor blackColor];
isEmpty = NO;
}
return YES;
}
- (void) textViewDidEndEditing:(UITextView*)textView {
if(comments.text.length == 0){
comments.textColor = [UIColor lightGrayColor];
comments.text = @"Comments";
isEmpty = YES;
}
}
@syxc
Copy link
Author

syxc commented Dec 17, 2012

Android中的hint属性,iOS中的placeholder属性!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment