iOS 응용 (swift)
[iOS - swift] textField의 placeholder색깔 변경 방법
jake-kim
2021. 3. 9. 22:42

Code로 접근 방법
- attributedPlaceholder 속성 사용
extension UITextField {
func setPlaceholder(color: UIColor) {
guard let string = self.placeholder else {
return
}
attributedPlaceholder = NSAttributedString(string: string, attributes: [.foregroundColor: color])
}
}
- 색깔 변경
textField.setPlaceholder(color: .blue)
xib에서 접근 방법
- User Defined Runtime Attributes에서 속성 추가: placeholderLabel.textColor


- 결과
