mySearchBar.tintColor = [UIColorwhiteColor];
mySearchBar.barTintColor = kRedHuangColor;
mySearchBar.backgroundImage = [UIImageimageWithColor:kRedHuangColorsize:CGSizeMake(kScreenWidth, 40)];
[mySearchBarbecomeFirstResponder];
mySearchBar.hidden = NO;
mySearchBar.showsCancelButton = YES;
UIButton *cancelButton;
UIView *topView = mySearchBar.subviews[0];
for (UIView *subView in topView.subviews) {
if ([subView isKindOfClass:NSClassFromString(@"UINavigationButton")]) {
cancelButton = (UIButton *)subView;
}
}
if (cancelButton) {
[cancelButton setTitle:@"取消"forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColorwhiteColor] forState:UIControlStateNormal];
cancelButton.titleLabel.tintColor = [UIColor whiteColor];
}