I was wondering how to display a default prompt in a UITextView. If I wanted the user to type a description in a text view, the UITextView could have "description" printed in it, and when the user starts to type, it disappears.
For UITextField
, there is the placeholderText
property, which will display a grayed out text that is removed once the user starts typing.
For UITextView
, you can use a custom implementation, such as SZTextView
, which implements a similar functionality of a placeholder text.
It wont be a wise idea to use a third party uitextview for placeholder property. Follow these steps and you will achieve what you need-
set- textview.textcolor=[uicolor greycolor];
textview.text=@"Your initial placeholder text";
Now in -textViewShouldBeginEditing write these lines of codes-
if(textview.color==[uicolor greycolor]){
textview.color=[uicolor blackcolor];
textview.text=@"";
}
Cheers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With