Created
May 9, 2012 22:15
-
-
Save jagbolanos/2649319 to your computer and use it in GitHub Desktop.
UITextView with Hint Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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