Skip to content

Instantly share code, notes, and snippets.

@jagbolanos
Created May 9, 2012 22:15
Show Gist options
  • Save jagbolanos/2649319 to your computer and use it in GitHub Desktop.
Save jagbolanos/2649319 to your computer and use it in GitHub Desktop.
UITextView with Hint Text
- (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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment