NavigationBarTitleSwiftUI中watchOS的颜色更改 [英] NavigationBarTitle color change for watchOS in SwiftUI

查看:255
本文介绍了NavigationBarTitleSwiftUI中watchOS的颜色更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

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