Has anyone any idea or code sample on how can I change the text color of the placeholder text of a UISearchBar?
iOS 13
Previous solutions may not work on iOS 13 because new searchTextField has been added, and you can set attributed string on it.
I wrapped that into category:
@interface UISearchBar (AttributtedSetter)
- (void)setThemedPlaceholder:(NSString*)localizationKey;
@end
@implementation UISearchBar (AttributtedSetter)
- (void)setThemedPlaceholder:(NSString*)localizationKey {
ThemeObject *currentTheme = [[ThemeManager standardThemeManager] currentTheme];
self.searchTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:NSLocalizedString(localizationKey, @"") attributes:@{NSForegroundColorAttributeName : currentTheme.colorSearchBarText}];
}
@end