How to change color of back button on NavigationView

后端 未结 6 1682
情书的邮戳
情书的邮戳 2021-01-02 04:56

When you click on the button it takes you to a new view and puts a back button in the top left. I can\'t figure out what property controls the color of the back button. I tr

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 05:21

    You can use the accentColor property on the NavigationView to set the back button color, like in this example:

    var body: some View {
        NavigationView {
            List(1..<13) { item in
                NavigationLink(destination: Text("\(item) x 8 = \(item*8)")) {
                    Text(String(item))
                }
            }.navigationBarTitle("Table of 8")
        }.accentColor( .black) // <- note that it's added here and not on the List like navigationBarTitle()
    }
    

提交回复
热议问题