CustomScopeBar: Fix search bar placement

iOS 16 has a new search bar placement value which applies the searchbar
in the top-right corner with iPads. Searchable does this automatically,
but SwiftUIx's modifier needs this fix.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2023-03-05 23:51:21 -05:00
parent d504369e98
commit 618041714d

View file

@ -51,6 +51,10 @@ struct CustomScopeBarModifier<V: View>: ViewModifier {
self.hostingController = hostingController
}
.introspectNavigationController { navigationController in
if #available(iOS 16, *) {
navigationController.viewControllers.first?.navigationItem.preferredSearchBarPlacement = .stacked
}
navigationController.navigationBar.prefersLargeTitles = true
navigationController.navigationBar.sizeToFit()
}