修改searchbar 取消 字体 颜色

时间:2023-03-10 08:30:13
修改searchbar 取消 字体 颜色
    UIButton *cancelButton;
UIView *topView = self.searchDisplayController.searchBar.subviews[];
for (UIView *subView in topView.subviews) {
if ([subView isKindOfClass:NSClassFromString(@"UINavigationButton")]) {
cancelButton = (UIButton*)subView;
}
}
if (cancelButton) {
//Set the new title of the cancel button
[cancelButton setTitle:@"取消" forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor colorWithRed:.f/.f green:.f/.f blue:.f/.f alpha:1.0] forState:UIControlStateNormal];
cancelButton.titleLabel.font = [UIFont fontWithName:@"Heiti SC" size:];
}