Skip to content

Instantly share code, notes, and snippets.

@0xKayvan
Created April 24, 2015 16:06
Show Gist options
  • Save 0xKayvan/827d130de6a9c89b8345 to your computer and use it in GitHub Desktop.
Save 0xKayvan/827d130de6a9c89b8345 to your computer and use it in GitHub Desktop.
uiTextView placeholder trick
-(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