UISearchBar是一个比较复杂的控件,其中有很多控件,修改UISearchBar外观,比较常用的就是修改其中TextField 的属性.
[self.searchBar.searchTextFieldsetBackgroundColor:HEXCOLOR(@"F5F5F5")];
[self.searchBarsetBackgroundImage:[UIImagenew]];
用KVC拿到私有属性,对textfiled赋值.


当然,也可以自定义类,继承自UISearchBar,自定义属性,重写setter方法.
同理,如果要在UISearchBar里面加一个自定义的控件,可以用 [textField addSubView:customView],布局相对于textField.
网友评论