SwiftUI更改导航带按钮的Bartitle颜色
我可以在触摸按钮时更改navigationBarTitle颜色吗SwiftUI更改导航带按钮的Bartitle颜色,swiftui,navigationbar,Swiftui,Navigationbar,我可以在触摸按钮时更改navigationBarTitle颜色吗 NavigationView { ZStack { Color(ThemeManager.shared().generalBackgroundColor) .edgesIgnoringSafeArea(.all) } .navigationBarTitle("Change theme sample").foregroundColor(.blue) } 您当前无法以本机
NavigationView {
ZStack {
Color(ThemeManager.shared().generalBackgroundColor)
.edgesIgnoringSafeArea(.all)
} .navigationBarTitle("Change theme sample").foregroundColor(.blue)
}
您当前无法以本机方式更改SwiftUI中的导航栏属性,因此您的
.foregroundColor(.blue)
将只更改该屏幕上的所有前景色
您可以使用类似的方法访问UINavigationController
,然后使用navigationController.navigationBar.largeTitleTextAttributes=[NSAttributedStringKey.foregroundColor:UIColor.blue]
更改大标题栏