Manohar Nikam
Manohar Nikam

Reputation: 21

PlaceholderColor not set to PlaceHolderLabel for UITextfield in ios13

self.setValue(placeHolderColor, forKeyPath: "_placeholderLabel.textColor")

in ios13 its crashed.how to set placeholderColor to placeholderLabel in swift5 for ios13 in xcode11.

Upvotes: 2

Views: 354

Answers (1)

Kamran
Kamran

Reputation: 15258

Set color using attributedPlaceholder as below,

let colorAttrbs: [NSAttributedString.Key: Any] = [.foregroundColor: UIColor.red]
textField.attributedPlaceholder = NSAttributedString(string: "placeholder", attributes: colorAttrbs)

Upvotes: 3

Related Questions