Friday, November 6, 2026
HomeiOS Developmentios - Learn how to solely apply most popular colour scheme to...

ios – Learn how to solely apply most popular colour scheme to 1 view and never the remainder of the views within the view hierarchy in SwiftUI

[ad_1]

I’m attempting to make one view render in darkish mode whereas the remainder of my app is within the customers chosen colour scheme. After I apply .preferredColorScheme(.darkish) to the subview, it causes different views to show darkish as effectively. How can I repair this conduct?

ContentView:

NavigationView {
    ZStack {
        NavigationLink(isActive: $showingGoalDashboardView) {
            TestView(purpose: targets.first!)
        } label: {
            EmptyView()
        }
                
        NavigationLink(isActive: $showingCreateGoalView) {
            CreateGoalView(showingGoalCreateView: $showingCreateGoalView)
        } label: {
            EmptyView()
        }
                
        LoadingView()
    }
}

LoadingView:
LoadingView simply comprises some UI components, all wrapped in a ZStack with the property .preferredColorScheme(.darkish) utilized to it.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments