//修改搜索框背景

    self.searchCarKeyWord.backgroundColor=[UIColorclearColor];

    //去掉搜索框背景

    //1.

    [[self.searchCarKeyWord.subviewsobjectAtIndex:0]removeFromSuperview];

    //2.

    //CGRect rcSearchBg =  CGRectMake(0, 0, self.searchBar.frame.size.width, self.searchBar.frame.size.height);

    UITextField *searchField;

    UIButton *cancelButton;

    for (UIView *subview inself.searchCarKeyWord.subviews)

    {

        if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])

        {

            //rcSearchBg = subview.frame;

            [subview removeFromSuperview];

        }

        elseif([subview isKindOfClass:[UITextFieldclass]]){

            searchField = (UITextField*)subview;

        }

        elseif([subview isKindOfClass:[UIButtonclass]]){

            cancelButton = (UIButton*)subview;

        }

    }

    UIImage *backImage = [NormalUtilsstretchableImage:@"search_bg.png"stretchableImageWithLeftCapWidth:50topCapHeight:25];

    [searchField setBackground: backImage];

    [searchField setBorderStyle:UITextBorderStyleNone];

    [cancelButton setImage:[UIImageimageNamed:@"top_oval_bg.png"] forState:UIControlStateNormal];

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2021-05-20
  • 2022-01-22
  • 2021-11-11
  • 2021-11-26
  • 2021-10-29
猜你喜欢
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-11-20
相关资源
相似解决方案