简单的替换掉 image 就好了
这里UIImage 的高度设置和searchBar 一样高,宽度就随意了
UIImage* img =[UIImage imageWithColor:UIColor.whiteColor size:CGSizeMake(100, 40)];
[_searchBar setSearchFieldBackgroundImage:img forState:UIControlStateNormal];
默认的搜索控件有灰色背景
![](https://img.haomeiwen.com/i4031301/94c82203ce90fac0.png)
需要的效果为
![](https://img.haomeiwen.com/i4031301/7da60580b5bfcb58.png)
简单的替换掉 image 就好了
这里UIImage 的高度设置和searchBar 一样高,宽度就随意了
UIImage* img =[UIImage imageWithColor:UIColor.whiteColor size:CGSizeMake(100, 40)];
[_searchBar setSearchFieldBackgroundImage:img forState:UIControlStateNormal];
默认的搜索控件有灰色背景
需要的效果为
本文标题:去掉UISearchBar 默认的灰色背景
本文链接:https://www.haomeiwen.com/subject/nveeprtx.html
网友评论