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([subViewisKindOfClass:NSClassFromString(@"UINavigationButton")]) {
cancelButton = (UIButton *)subView;
}
}
if (cancelButton) {
[cancelButtonsetTitle:@"取消"forState:UIControlStateNormal];
[cancelButtonsetTitleColor:[UIColorwhiteColor]forState:UIControlStateNormal];
cancelButton.titleLabel.tintColor = [UIColor whiteColor];
}