1.改变searchbar的searchField属性

 UITextField *searchField = [searchbar valueForKey:@"searchField"];

    if (searchField) {

        // 背景色

        [searchField setBackgroundColor:[UIColor colorWithRed:0.074 green:0.649 blue:0.524 alpha:1.000]];

        // 设置字体颜色 & 占位符 (必须)

        searchField.textColor = [UIColor whiteColor];

//        searchField.placeholder = @"placeholder";

        // 根据@"_placeholderLabel.textColor" 找到placeholder的字体颜色

        [searchField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];

        // 圆角

        searchField.layer.cornerRadius = 10.0f;

        searchField.layer.masksToBounds = YES;

    }

    2.改变searchBarde 图标样式

[self.searchBar setImage:[UIImage imageNamed:@""] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];

 

posted on 2018-03-23 16:55  强者VS弱者  阅读(289)  评论(0编辑  收藏  举报