Xcode 11-SwiftUI的黑暗模式设置 [英] Xcode 11 -- SwiftUI's dark mode setup

查看:32
本文介绍了Xcode 11-SwiftUI的黑暗模式设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的.我知道这不应该是火箭科学.我似乎无法使用暗模式,并且已经阅读了几次文档.希望有人能找出我所缺少的东西.

Okay. I know this shouldn't be rocket science. I can't seem to get dark mode working and I've read the documentation a few times. Hoping someone can pick out what I'm missing.

我在资产目录中有一种命名的颜色.

I have an named color in the asset catalog.

我将plist模式设置为暗模式,以便于测试.

I set my plist mode to be in dark mode for easier testing.

我的内容视图如下:

struct ContentView : View {
var body: some View {
    VStack {
        Text("Hello World")
        Text("Yo yo yo")
            .color(Color("darkModeColor"))
    }

}

}

无论我做什么,当它应该呈现青色时,颜色总是"Any"外观.

No matter what I do, the color is ALWAYS of the "Any" appearance when it should be taking on the cyan color.

我知道深色模式本身可以工作,因为苹果提供的所有系统语义颜色都可以正常工作,因为您可以看到"Hello World"文本变为白色.

I know dark mode itself works because all the system semantic colors provide by apple are working just fine as you can see the "Hello World" text changed to white.

有什么主意我想念的东西吗?还是其他人遇到了Xcode 11 Beta 1的问题?

Any ideas what I'm missing or is anyone else running into this issue with Xcode 11 Beta 1?

推荐答案

这可能是Xcode 11 Beta版中的一个错误.我在UIKit应用程序中尝试了暗模式功能,并且使用 UIColor可以正常工作,但是在SwiftUI中使用 Color 不能使用相同的颜色.希望在以后的版本中可以解决此问题.

This is probably a bug in this beta release of Xcode 11. I tried the dark mode feature in a UIKit application and it is working perfectly using UIColor but the same color wouldn’t work using Color in SwiftUI. Hopefully this will be fixed in the next releases.

更新:此问题已通过 Xcode 11 beta 3 修复.

Update: This issue was fixed with Xcode 11 beta 3.

这篇关于Xcode 11-SwiftUI的黑暗模式设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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