I currently have a text view with placeholder text that dissapears whenever a user taps on the text view and the text in the textview reappears whenever the first responder is resigned, if the text view is empty. (Heres the code I use for that in case anyone wants to use it)
*Note, first set the text color of the textview to light gray and set the placeholder text. Then use these methods:
func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
//If it begins editing, then set the color to black
if (textView.tag == 0){
textView.text = ""
textView.textColor = .black
textView.tag = 1
}
return true
}
func textViewDidEndEditing(_ textView: UITextView) {
if textView.text.isEmpty {
textView.text = "Example: I started my career as a street wear model based in Maryland. After 3 years of working with some of the top companies there, I moved to LA, where I currently reside. I’ve been featured in shows, 12 magazines, commercials, and a number of music videos. Now, Im currently looking to continue working with clothing companies and campaigns."
textView.textColor = .lightGray
textView.tag = 0
}
}
I wanted to step things up a notch. Right now, the text disappears whenever the text view becomes the first responder. I want the text to disappear whenever the user actually starts typing, not just when the text view is selected. When the screen appears, I automatically set the first responder to the text view and I plan on keeping it that way. But because its automatically set, you're not able to see the placeholder text. I only want the text view to disappear whenever the user presses a key, not because its selected.