UISearchBar change placeholder color

前端 未结 17 2444
南旧
南旧 2020-12-04 15:16

Has anyone any idea or code sample on how can I change the text color of the placeholder text of a UISearchBar?

17条回答
  •  我在风中等你
    2020-12-04 16:06

    Try this:

    [self.searchBar setValue:[UIColor whatever] forKeyPath:@"_searchField._placeholderLabel.textColor"];
    

    You can also set this in storyboard, select search bar, add entry under User Defined Runtime Attributes:

    _searchField._placeholderLabel.textColor
    

    of type Color and select the color you need.

提交回复
热议问题