UISearchBar: Changing the appearance - Shape, Background, Overlay an Image

僤鯓⒐⒋嵵緔 提交于 2019-12-01 11:18:19

问题


I'd like to change the appearance of the default UISearchBar. As an example, how would you recreate the search box in the Google iPhone app as seen below? How would you overlay an image to produce this effect?


(source: isedb.com)


回答1:


Upon some investigating of possibilites to customize the search bar, I'm inclined to say this is a custom component that has nothing to do with UISearchBar, but instead recreates its functionality.




回答2:


You don't need to subclass anything. Create a new UIView that has the buttons and text field and then when then entire view is going to load do this:

[self.searchDisplayController.searchBar addSubview:customSearchBarView];

Make sure to set the new text field as the first responder so it has access to the keyboard.



来源:https://stackoverflow.com/questions/2370002/uisearchbar-changing-the-appearance-shape-background-overlay-an-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!