Posts

Post not yet marked as solved
3 Replies
4.9k Views
Hi, I want to chnage searchbar's placeholder textcolor but couldn’t achieve it.I approached in three ways to achieve this;1) Get placeholderlabel through KVC.: searchbar.value(forKey: "placeholderLabel") to change label textcolor.But failed with keyundefinederror.(which worked well in iOS12 with custom search bar. )2) Get textfield and change textfield's placeholderLabel color.: tf = searchbar.searchTextField: tf.setValue(UIColor.***, forKeyPath: "placeholderLabel.textColor")But failed with no exceptions.(which worked well if I used just the textfield to change its placeholder color)3) AttributedString.: searchbar.searchTextField.attributedPlaceholder = NSAttributedString(string: "test", attributes: [NSAttributedString.Key.foregroundColor: UIColor.***])But failed.What can I do to change UISearchbar's placeholder's textcolor?Thanks.
Posted Last updated
.