如何在NavigationView上更改后退按钮的颜色 [英] How to change color of back button on NavigationView

查看:149
本文介绍了如何在NavigationView上更改后退按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您单击按钮时,它将带您进入新视图,并在左上角放置一个后退按钮.我不知道哪个属性控制后退按钮的颜色.我尝试添加accentColor和前景颜色,但它们仅编辑视图中的项目.

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 tried adding an accentColor and foregroundColor but they only edit the items inside the view.

var body: some View {
    NavigationView {
        NavigationLink(destination: ResetPasswordView()) {
            Text("Reset Password")
            .foregroundColor(Color(red: 0, green: 116 / 255, blue: 217 / 255))
            .padding()
        }
    }
}

推荐答案

您可以在NavigationView上使用accentColor属性来设置后退按钮的颜色,如本示例所示:

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()
}

这篇关于如何在NavigationView上更改后退按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆