替换UISearchBar的取消按钮

 

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];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值