UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

tint color

Forums > SwiftUI

I have a general question. In SwiftUI when presenting a sheet how do you get that sheet to accept the accent color of the previous view.

Does anyone know how to do this? Because what Im doing is now working.

Here is the view that I want the accent color to work on.

    var body: some View {
        HStack(alignment: .center) {
            Button(action: {
                // ACTION HERE
            }) {
                Image(systemName: "plus.circle.fill")
                    .font(.title)
            }.accentColor(Color("ChurchGreen"))

            HStack(alignment: .center) {
                Text("\(hymnData.songNum): ").foregroundColor(.gray)
                    .frame(width: 38, height: 30, alignment: .trailing)
                Text("\(hymnData.songName)")
                    .lineLimit(1)
            }
        }
    }

3      

Hello! I am not the real expert, but I solved this problem in my project in Xcode 12 (iOS 14) with defining accent color in the Assets folder. Here you can define an accent color for light and dark mode. than it will appear automatically wherever an accentcolor is used by the system. I hope it will work for you as well. Br, Martin

3      

Prior to Xcode 12, sheets did not inherit the Environment of their presenter so you had to set it separately.

3      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.