更改导航按钮 SwiftUI 的颜色
Change color of Navigation Button SwiftUI
如何将导航“后退按钮”(自动创建)的颜色更改为黑色,
并将 DisclosureGroup“Chevron”的颜色更改为另一种颜色?
我试过 .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()
}
}
在这种情况下使用.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)
}
}
如何将导航“后退按钮”(自动创建)的颜色更改为黑色, 并将 DisclosureGroup“Chevron”的颜色更改为另一种颜色?
我试过 .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()
}
}
在这种情况下使用.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)
}
}