NavigationBarTitleSwiftUI中watchOS的颜色更改 [英] NavigationBarTitle color change for watchOS in SwiftUI
问题描述
在id上方的图像中,喜欢将-02:49
更改为诸如Color.blue
In the image above id like to change -02:49
to a color such as Color.blue
我尝试过:
struct ContentView: View {
var body: some View {
PlayerView().accentColor(Color.blue)
}
}
和 我还尝试过将其添加到实际的PlayerView中,如下所示:
and I've also tried adding it in the actual PlayerView as follows:
struct PlayerView: View {
var body: some View {
VStack{
....
}.navigationBarTitle(Text("-2:49"))
.accentColor(.blue)
}
}
我也尝试过:
struct PlayerView: View {
var body: some View {
VStack{
....
}.navigationBarTitle(Text("-2:49").foregroundColor(.blue))
}
}
推荐答案
这时要更改navigationBarTitle的颜色,它们在SwiftUI中不是直接的api.
但是您可以像这样更改它,
1)转到AppName WatchKit App
中的Interface.storyboard
文件.
2)选择Hosting Controller Scene
,转到File Inspector
,然后将Global Tint
更改为您的自定义颜色.
At this point for change color of navigationBarTitle their is no direct api in SwiftUI.
But you can change it like this,
1) Go to Interface.storyboard
file inside your AppName WatchKit App
.
2) Select Hosting Controller Scene
, Go to File Inspector
and change Global Tint
to your Custom Color.
这篇关于NavigationBarTitleSwiftUI中watchOS的颜色更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!