iOS 13 引入了语义颜色:一种指定颜色用途而不是其实际值的方式。这允许颜色在启用暗模式时自动适应。
UIKit中,这些颜色可以很容易地通过对静态成员访问UIColor(例如UIColor.label(),UIColor.secondaryLabel()等)。可以在此文档页面上找到所有可用语义颜色的详细列表。
但是,SwiftUI 的Color类型没有等效的静态成员。因此,这将是无效的:
// Error: Type 'Color?' has no member 'secondaryLabel'
var body: some View {
Text("Hello World!")
.color(.secondaryLabel)
}
Run Code Online (Sandbox Code Playgroud)
我将如何在 SwiftUI 中访问这些语义颜色?
我正在通过 UglifyJS 发送一个脚本,其中包含一些可选更改语法的实例。在浏览器中,这种语法可以完美地工作。但是,UglifyJS 在文件上产生以下错误:
\nParse error at /Users/username/Developer/script.js:84,32\n node.children[0]?.tagName === "P";\n ^\nERROR: Unexpected token: punc \xc2\xab.\xc2\xbb\n at JS_Parse_Error.get (eval at <anonymous> (/opt/homebrew/lib/node_modules/uglify-js/tools/node.js:18:1), <anonymous>:71:23)\n at fatal (/opt/homebrew/lib/node_modules/uglify-js/bin/uglifyjs:428:27)\n at run (/opt/homebrew/lib/node_modules/uglify-js/bin/uglifyjs:366:9)\n at Object.<anonymous> (/opt/homebrew/lib/node_modules/uglify-js/bin/uglifyjs:275:5)\n at Module._compile (node:internal/modules/cjs/loader:1092:14)\n at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)\n at Module.load (node:internal/modules/cjs/loader:972:32)\n at Function.Module._load (node:internal/modules/cjs/loader:813:14)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)\n at node:internal/main/run_main_module:17:47\nRun Code Online (Sandbox Code Playgroud)\n我已经浏览了文档,但我不确定要添加哪些参数(如果有)才能完成这项工作。
\n