尝试遵循这个 iOS dev tutorial.
\n当我到达第 7 步时,代码没有按预期更改背景颜色。
\n引用“步骤 7\n添加一个名为 mainColor 的颜色属性,该属性使用枚举\xe2\x80\x99s rawValue 创建颜色。\n此属性从资产目录初始化颜色。”
\n这是主题文件中的代码:
\nimport SwiftUI\n\nenum Theme: String {\n case bubblegum\n case buttercup\n case indigo\n case lavender\n case magenta\n case navy\n case orange\n case oxblood\n case periwinkle\n case poppy\n case purple\n case seafoam\n case sky\n case tan\n case teal\n case yellow\n \n var accentColor: Color {\n switch self {\n case .bubblegum, .buttercup, .lavender, .orange, .periwinkle, .poppy, .seafoam, .sky, .tan, .teal, .yellow: return .black\n case .indigo, …Run Code Online (Sandbox Code Playgroud)