更改导航按钮 SwiftUI 的颜色

时间:2020-12-31 16:14:22

标签: swift swiftui swiftui-navigationview

如何将导航“返回按钮”(它是自动创建的)的颜色更改为黑色, 和 DisclosureGroup "Chevron" 的颜色变成另一种颜色?

enter image description here

我已经尝试过 .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()
    }
}

1 个答案:

答案 0 :(得分:3)

在这种情况下使用 val

demo

const Joi = require('joi')

let externalVar = true

module.exports = Joi.object({
  username: Joi.string().alphanum().min(3).max(30).required(),
  password: Joi.string().pattern( /^[a-zA-Z0-9]{3,30}$/ ).required(),

  // here
  role: Joi.number().when(externalVar, { is: false, then: Joi.required(), otherwise: null })
})

添加

<input id="drop" type="checkbox"/>