Reputation: 1111
I am trying to make the navigation bar transparent using init(), but I get the error "Return from initializer without initializing all stored properties" and I don't know how to solve it. Here is my code:
import SwiftUI
struct DoctorHomePage: View {
@Binding var shouldPopToRootView : Bool
@State var hiddingNavBar = true
@State private var curent: Int? = nil
@State private var profileSegue: Int? = nil
@State private var isActive: Bool = false
let defaults = UserDefaults.standard
let networkRequest = Network()
@State var cancelable: AnyCancellable? = nil
@State var localPatients : [Patients] = []
@Environment(\.colorScheme) var colorScheme: ColorScheme
@State private var isShowing = false
init() {
UINavigationBar.appearance().backgroundColor = .clear
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
} // I get the error here
var body: some View {
NavigationView {
VStack {
Text("Hello, World!")
}
}
}
}
Upvotes: 1
Views: 4057