본문 바로가기
개발/ios (swift)

UITextview Placeholder

by 즐거운 개발 인생 2022. 3. 3.
728x90
반응형

 

override func viewDidLoad() {
    super.viewDidLoad()
    
    self.contentTextView.delegate = self
    self.contentTextView.text = "content".localized()
}
    func textViewDidBeginEditing(_ textView: UITextView) {
        if textView.textColor == UIColor.lightGray{
            textView.text = ""
            textView.textColor = UIColor.darkGray
        } else {
            textView.text = "content".localized()
            textView.textColor = UIColor.lightGray
        }
    }
   
    
    func textViewDidEndEditing(_ textView: UITextView) {
        if textView.text.count == 0 {
            textView.text = "content".localized()
            textView.textColor = UIColor.lightGray
        } else {
            textView.textColor = UIColor.darkGray
        }
    }

 

 

 

728x90
반응형

댓글