ios 修改UISearchBae placeholder的颜
2023-03-13 本文已影响0人
天上飞的狒狒
UITextField *textfield;
if (@available(iOS 13.0, *)) {
textfield = [_searchBar searchTextField];
} else {
textfield = [_searchBar valueForKey:@"_searchField"];
}
//修改placeHolder的颜色
NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:@"输入标题、简介" attributes:@{NSForegroundColorAttributeName : [UIColor lightGrayColor]}];
textfield.attributedPlaceholder = placeholderString;