1

如何将导航“后退按钮”(自动创建)的颜色更改为黑色,将 DisclosureGroup“雪佛龙”的颜色更改为另一种颜色?

在此处输入图像描述

我试过做.buttonStyle(PlainButtonStyle()).foregroundColor(.black)

struct ContentView: View {

    var body: some View {
    
        NavigationView {
            NavigationLink(destination: DetailView()) {
        
                Text("Go to details ->")
                    .foregroundColor(.purple)
                    .underline()
            }
        }
    }
}


struct DetailView: View {
    @State private var isExpanded = false
    
    var body: some View {
        VStack {
            DisclosureGroup("All Details", isExpanded: $isExpanded) {
                
            }.buttonStyle(PlainButtonStyle())
            .foregroundColor(.black)

            Spacer()
        }
        .padding()
    }
}
4

1 回答 1

3

用于.accentColor此类情况

演示

        DisclosureGroup("All Details", isExpanded: $isExpanded) {
            
        }
        .accentColor(.black)

添加

struct ContentView: View {

    var body: some View {
    
        NavigationView {
            NavigationLink(destination: DetailView()) {
        
                Text("Go to details ->")
                    .foregroundColor(.purple)
                    .underline()
            }
        }.accentColor(.black)
    }
}
于 2020-12-31T16:21:49.813 回答