未通过SwiftUI从资产加载颜色

问题描述 投票:0回答:1

我有这个简单的观点:

struct SplashscreenView: View {
    var body: some View {
        ZStack {
            Color("primary").edgesIgnoringSafeArea(.all)
            Text("Hello, World!")
        }

    }
}

primary中定义了颜色[:

Assets.xcassets

但是在我看来,颜色不会显示:

enter image description here

如果我强制使用系统的颜色,例如Color.red,则会正确显示颜色。

swiftui uicolor xcasset
1个回答
0
投票
将颜色与Bundle的init初始化方法一起使用...

检查此:enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.