UIButton *cancelButton;
UIView *topView = self.searchDisplayController.searchBar.subviews[0];
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:53.f/255.f green:114.f/255.f blue:255.f/255.f alpha:1.0] forState:UIControlStateNormal];
cancelButton.titleLabel.font = [UIFont fontWithName:@"Heiti SC" size:15];
}
原来还有个方法
self.searchDisplayController.searchBar.tintColor = [UIColor colorWithRed:53.f/255.f green:114.f/255.f blue:255.f/255.f alpha:1.0];效果图
本文详细介绍了如何在iOS应用中修改UIButton的样式,包括设置标题、颜色和字体,并且展示了如何调整searchBar的颜色,提供了代码示例。

被折叠的 条评论
为什么被折叠?



