UISearchBar 设置背景色,去掉黑线

来源:互联网 发布:国泰君安富易交易软件 编辑:程序博客网 时间:2024/06/05 02:49

    self.searchBar = [[UISearchBaralloc]initWithFrame:CGRectMake(0,5, self.view.bounds.size.width,35)];

    self.searchBar.delegate =self;

    //设置背景色

    self.searchBar.barTintColor = [UIColorcolorWithRed:239/255.0green:240/255.0blue:244/255.0alpha:1.0];

    //设置右边的取消按钮

        for (id objin [self.searchBarsubviews]) {

            if ([objisKindOfClass:[UIViewclass]]) {

                for (id obj2in [obj subviews]) {

                    if ([obj2isKindOfClass:[UIButtonclass]]) {

                        UIButton *btn = (UIButton *)obj2;

                        [btn setTitle:@"取消"forState:UIControlStateNormal];

                    }

                }

            }

        }

    [self.searchBarsetBackgroundImage:[UIImagenew]]; //去掉多余的黑线

    

    [self.viewaddSubview:self.searchBar];



0 0
原创粉丝点击