How can I add a placeholder in a UITextView
, similar to the one you can set for UITextField
, in Swift
?
Updated for Swift 4
UITextView
doesn't inherently have a placeholder property so you'd have to create and manipulate one programmatically using UITextViewDelegate
methods. I recommend using either solution #1 or #2 below depending on the desired behavior.
Note: For either solution, add UITextViewDelegate
to the class and set textView.delegate = self
to use the text view’s delegate methods.
Solution #1 - If you want the placeholder to disappear as soon as the user selects the text view: