【发布时间】:2023-02-15 14:23:45
【问题描述】:
我正在尝试创建一个 MenuBarExtra 允许图标根据 bool 的不同颜色。类似于 This,但图标内的数字变了颜色。
由于 MenuBarExtra 初始值设定项要求字符串而不是视图(我试图以具有属性更改的图像形式传递),因此我无法为图标重新着色
这是我想要的:
MenuBarExtra("label", systemImage: Image(systemName: "circle").foregroundColor(.red))
我收到此错误:
Cannot convert value of type 'some View' to expected argument type 'String'
我可以将“圆”作为 systemImage 的参数传递,但不能传递图像。当需要字符串时,有什么方法可以更改 systemImage 属性吗?
【问题讨论】:
-
你能分享整个代码吗?