How to add placeholder text to UITextView in Swift?
Hi everyone! I'm a beginner iOS developer writing in Swift. I've encountered a problem: UITextField has a built-in `placeholder` property that shows gray hint text while the field is empty. But UITextView doesn't have such a property.
I need to create a multi-line text input field (for example, for a comment or description) so that when the user hasn't entered anything yet, a hint "Enter your text..." is displayed. As soon as the user starts typing, the placeholder should disappear. If the user deletes all the text, the placeholder should reappear.
I tried using a `UILabel` placed on top of the UITextView, but it doesn't disappear when I start typing, or it remains visible if the text is empty.
Here's my current code:
```swift
import UIKit
class ViewControll
No answers yet.
Log in to leave an answer
Blogs
CI/CD for Rust Projects: GitHub Actions — Part 2