如何初始化shouldPopToRootView
?这是我的代码:
import SwiftUI
struct DoctorHomePage: View {
@Binding var shouldPopToRootView : Bool
init() {
UINavigationBar.appearance().backgroundColor = .clear
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
}
var body: some View {
NavigationView {
VStack {
Text("Hello, World!")
}
}
}
}
答案 0 :(得分:2)
检查一下:
struct DoctorHomePage: View {
@Binding var shouldPopToRootView : Bool
init(shouldPopToRootView: Binding<Bool>) {
self._shouldPopToRootView = shouldPopToRootView
UINavigationBar.appearance().backgroundColor = .clear
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
} // I get the error here
var body: some View {
NavigationView {
VStack {
Text("Hello, World!")
}
}
}
}
struct ContentView: View {
var body: some View {
DoctorHomePage(shouldPopToRootView: .constant(true))
}
}