SwiftUI通过按钮[duplicate]更改navigationBarTitle颜色

问题描述 投票:1回答:1

我是否可以在触摸按钮时更改navigationBarTitle颜色?

NavigationView {
    ZStack {
        Color(ThemeManager.shared().generalBackgroundColor)
            .edgesIgnoringSafeArea(.all)
    }    .navigationBarTitle("Change theme sample").foregroundColor(.blue)
}
swiftui navigationbar
1个回答
0
投票

您目前无法在本机上更改SwiftUI的导航栏属性,因此您的.foregroundColor(.blue)只会更改该屏幕上的前景色[[all。

您可以使用this answer之类的东西来访问UINavigationController,然后用navigationController.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.blue]更改大标题栏。
© www.soinside.com 2019 - 2024. All rights reserved.