Created
September 9, 2014 17:27
-
-
Save chrisdiana/aa64509aa50c518c54a5 to your computer and use it in GitHub Desktop.
Placeholder for UITextView in Xamarin
This file contains hidden or 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
// sample text box | |
var descriptionField = new UITextView (new RectangleF (0, 230, UIScreen.MainScreen.Bounds.Width, 100)){ | |
BackgroundColor = UIColor.White, | |
Text = " Description:", | |
TextColor = ViewHelpers.DarkGray, | |
Font = UIFont.FromName("Helvetica", 18f) | |
}; | |
// some work arounds for UITextView placeholders | |
var Placeholder = " Description:"; | |
descriptionField.ShouldBeginEditing = t => { | |
if (descriptionField.Text == Placeholder) { | |
descriptionField.Text = string.Empty; | |
} | |
return true; | |
}; | |
descriptionField.ShouldEndEditing = t => { | |
if (string.IsNullOrEmpty (descriptionField.Text)) { | |
descriptionField.Text = Placeholder; | |
} | |
return true; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment