I have been searching thru the web but cant find a confirmed answer. There are ways like removing the subview within the searchbar.subviews but is that allowed?
If not then, aside from changing the tintColor of SearchBar, or use a textfi开发者_JAVA百科eld instead, is there a way that wont break apple's rule and still being able to customize the background of searchBar?
Thanks!
You are not breaking apple's rules if you are not conflicting with private API's.
I worked on a shipping app that made the background of the search bar transparent. There were no problems with this.
A solution I've seen used a lot (albeit only on toolbars and navigation bars, so I'm not 100% sure it'll work the same way): subclass UISearchBar
and override its -drawRect:
, drawing your own background image within the view's bounds.
精彩评论