UISearchBar: Changing the appearance - Shape, Back

2019-02-20 21:55发布

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?

alt text

2条回答
疯言疯语
2楼-- · 2019-02-20 22:16

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.

查看更多
时光不老,我们不散
3楼-- · 2019-02-20 22:16

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.

查看更多
登录 后发表回答