1. TextField 선언하기
private lazy var textView: UITextView = {
let textView = UITextView()
textView.delegate = self
textView.textColor = .secondaryLabel
textView.font = .systemFont(ofSize: 16.0, weight: .medium)
textView.text = "" // PlaceHolder Text 입력
return textView
}()
2. UITextViewDelegate - textViewDidBeginEditing 사용
extension ViewController: UITextViewDelegate{
func textViewDidBeginEditing(_ textView: UITextView) {
// TextColor가 secondaryLabel이 아닐 때 새로 입력
guard textView.textColor == .secondaryLabel else {return}
textView.text = nil
textView.textColor = .label
}
}728x90
'Develop > UIKit' 카테고리의 다른 글
| [iOS] storyboard에서 UIButton Image 오른쪽에 배치하기 (0) | 2024.06.09 |
|---|---|
| [iOS] UIButton titleLabel (0) | 2024.05.29 |
| [iOS] UICollectionViewCompositionalLayout (0) | 2024.03.09 |
| [iOS] UIScrollView (1) | 2024.03.09 |
| [iOS] @IBInspectable (0) | 2024.01.06 |