Saturday, January 6, 2024
HomeiOS Developmentios - ToolbarColorScheme change when again to earlier display screen programmatically utilizing...

ios – ToolbarColorScheme change when again to earlier display screen programmatically utilizing NavigationStack


I am utilizing navigationStack and I discovered that after I again programmatically as an alternative of utilizing default again button on navigation bar. My ToolbarColorScheme is change from darkish to white.
Right here is my demo to breed this bug, for some reasone I’ve to make use of navigation stack. So can anybody give me some solution to repair this drawback however preserve utilizing navigationStack.
Thankyou!

struct TestView: View {
    
    personal var bgColors: [Color] = [ .indigo, .yellow, .green, .orange, .brown ]
    
    @State personal var path: [Color] = []
    
    var physique: some View {
        NavigationStack(path: $path) {
            Record(bgColors, id: .self) { bgColor in
                NavigationLink(worth: bgColor) {
                    Textual content(bgColor.description)
                }
            }
            .toolbarColorScheme(.darkish, for: .navigationBar)
            .toolbarBackground(
                AppColor.blue,
                for: .navigationBar)
            .toolbarBackground(.seen, for: .navigationBar)
            .listStyle(.plain)
            .navigationDestination(for: Coloration.self) { coloration in
                VStack {
                    Textual content("(path.depend), (path.description)")
                        .font(.headline)
                    HStack {
                        ForEach(path, id: .self) { coloration in
                            coloration
                                .body(maxWidth: .infinity, maxHeight: .infinity)
                        }
                    }
                    Button {
                        path.removeLast()
                    } label: {
                        Textual content("Again")
                    }
                }
                .toolbarColorScheme(.darkish, for: .navigationBar)
                .toolbarBackground(
                    AppColor.blue,
                    for: .navigationBar)
                .toolbarBackground(.seen, for: .navigationBar)
            }
            .navigationTitle("Coloration")
        }
    }
}

Default state
enter image description here
When again by press again button
enter image description here



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments