how do i implement the search button?

Asked on 06/11/2025

1 search

To implement a search button in your app, you can follow the guidance provided in the session "Build a UIKit app with the new design" from WWDC 2025. Here are some key points to consider:

  1. Placement: On iPhone, the search bar can automatically move to the toolbar, making it easily accessible. If you already have a toolbar, include the search bar placement as a bar button item along with other bar buttons. This will position the search exactly where you want it, appearing either as an expanded field or a toolbar button, depending on available space.

  2. iPad Considerations: For iPad, follow the macOS toolbar pattern by placing the search at the trailing edge of the navigation bar. This is ideal for split views. To enable this behavior, set the search bar placement to allow external integration on the navigation item to true.

  3. Search Tab: If your app uses a tab bar, you can include a distinct tab for search. When tapped, the search button expands into a search field, and the other buttons collapse. This search tab view is a great place for placing search suggestions. To have the search field activate automatically when the search tab is tapped, set automatically activate search to true on that tab.

For more detailed guidance, you can refer to the Search chapter in the "Build a UIKit app with the new design" session.