我试图在swiftui中实现自己的导航视图。但是状态看起来不像导航栏一样透明。
使用.edgesIgnoringSafeArea(.top)
,它按预期工作。
但是我不知道我的自定义视图怎么了才能实现这一目标。
struct ExampleNavigationView<Content: View>: UIViewControllerRepresentable {
private var content: () -> Content
init(@ViewBuilder content: @escaping () -> Content){
self.content = content
}
func makeUIViewController(context: Context) -> UINavigationController {
let contentViewController = UIHostingController(rootView: content())
let navigationController = UINavigationController(rootViewController: contentViewController)
navigationController.navigationBar.prefersLargeTitles = false
contentViewController.navigationItem.title = "Search"
return navigationController
}
func updateUIViewController(_ uiViewController: UINavigationController, context: UIViewControllerRepresentableContext<ExampleNavigationView>) {}
}