Created
April 24, 2015 16:06
-
-
Save 0xKayvan/827d130de6a9c89b8345 to your computer and use it in GitHub Desktop.
uiTextView placeholder trick
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{ | |
[textView setDelegate:self]; | |
} | |
-(void) textViewDidBeginEditing:(UITextView *)textView{ | |
if ([textView.text isEqualToString:@"placeholder text here..."]) { | |
textView.text = @""; | |
textView.textColor = [UIColor blackColor]; //optional | |
} | |
[textView becomeFirstResponder]; | |
} | |
-(void) textViewDidEndEditing:(UITextView *)textView{ | |
if ([textView.text isEqualToString:@""]) { | |
textView.text = @"placeholder text here..."; | |
textView.textColor = [UIColor lightGrayColor]; //optional | |
} | |
[textView resignFirstResponder]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment