如何在 iOS 16 的 iPad 上返回标题下的 UISearchController?

Kre*_*DEL 6 styles ipad swift uisearchcontroller ios16

在 iPad 上,iOS 16 searchController 显示在右侧。像这样: 浏览器风格

如何返回 searchController 的“默认”视图?像这样: 标题下的 UISearchController

tho*_*dao 22

在 iOS 16 中,有一个新的属性preferredSearchBarPlacementnavigationItem您可以将其更改为,.stacked使其看起来像以前的 iOS 一样:

if #available(iOS 16.0, *) {
  navigationItem.preferredSearchBarPlacement = .stacked
}
Run Code Online (Sandbox Code Playgroud)