我是否可以在触摸按钮时更改navigationBarTitle颜色?
NavigationView {
ZStack {
Color(ThemeManager.shared().generalBackgroundColor)
.edgesIgnoringSafeArea(.all)
} .navigationBarTitle("Change theme sample").foregroundColor(.blue)
}
您目前无法在本机上更改SwiftUI的导航栏属性,因此您的.foregroundColor(.blue)
只会更改该屏幕上的前景色[[all。
UINavigationController
,然后用navigationController.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.blue]
更改大标题栏。