MySearch = [[UISearchBaralloc]initWithFrame:CGRectMake(0,0,KWIDTH,60)];
MySearch.delegate=self;
MySearch.showsCancelButton=YES;
// [MySearch setTintColor:[UIColor redColor]]; //设置闪烁输入的头的颜色
// [MySearch setBarTintColor:[UIColor greenColor]]; //设置输入框的Bar的背景颜色
MySearch.placeholder=@"请输入客户名称、条码搜索...";
//遍历搜索条的上面的所有子视图,取下标为0的(Cancel按钮)取出Cancel上的所有子视图
for(UIView *viewin [[[MySearchsubviews]objectAtIndex:0]subviews])
{
//找到继承UINavigationButton类的View,继承过来
if([viewisKindOfClass:[NSClassFromString(@"UINavigationButton")class]])
{
//创建一个按钮,继承上面的继承的View
UIButton * cancel =(UIButton *)view;
cancel.bounds=CGRectMake(0,0,30,30);
// [cancel setImage:[UIImage imageNamed:@"01.png"] forState:UIControlStateNormal];
//[cancel setBackgroundImage:[UIImage imageNamed:@"01.png"] forState:UIControlStateNormal];
//[cancel setTitle:@"取消" forState:UIControlStateNormal];
[cancel setTintColor:[UIColorblackColor]];
[cancel.titleLabelsetTextColor:[UIColorblackColor]];
}
}
[self.viewaddSubview:MySearch];