Skip to content

Instantly share code, notes, and snippets.

@pierceboggan
Created January 25, 2014 23:22
Show Gist options
  • Save pierceboggan/8625385 to your computer and use it in GitHub Desktop.
Save pierceboggan/8625385 to your computer and use it in GitHub Desktop.
An easy way to implement your own UITextView placeholder field without subclassing.
public class CommentsTextDelegate : UITextViewDelegate
{
public override void EditingStarted (UITextView textView)
{
if (textView.Text == "Comments") {
textView.Text = "";
textView.TextColor = UIColor.Black;
textView.Font = FontConstants.SourceSansProRegular (13);
}
textView.BecomeFirstResponder ();
}
public override void EditingEnded (UITextView textView)
{
if (textView.Text == "") {
textView.Text = "Comments";
textView.TextColor = UIColor.LightGray;
textView.Font = FontConstants.SourceSansProBold (13);
}
textView.ResignFirstResponder ();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment