Clear UITextField Placeholder text on tap

后端 未结 10 1627
情书的邮戳
情书的邮戳 2021-01-31 04:33

In Xcode4 I\'ve created some placeholder text for a UITextField and I\'d like it to clear when the user taps in the box.

So, in the Attributes Inspector for the text fie

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-31 05:25

    In case of SWIFT 3 or later

    func textFieldDidBeginEditing(_ textField: UITextField) {
        textField.placeholder = nil
    }
    
    func textFieldDidEndEditing(_ textField: UITextField) {
        textField.placeholder = "Text Placeholder"
    }
    

提交回复
热议问题