Susca Bogdan
Susca Bogdan

Reputation: 1111

"Return from initializer without initializing all stored properties" error in SwiftUI

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

Answers (1)

Rob Napier
Rob Napier

Reputation: 299565

You haven't initialized shouldPopToRootView.

Upvotes: 3

Related Questions