I'm trying to create a MenuBarExtra that allows for the icon to be a different colour depending on a bool. Something like This but with a colour change instead of the number inside the icon.
I'm having trouble with recolouring the icon as the MenuBarExtra initializer asks for a string instead of a view (which I am trying to pass in the form of an Image with property changes)
Here is what I want:
MenuBarExtra("label", systemImage: Image(systemName: "circle").foregroundColor(.red))
I get this error:
Cannot convert value of type 'some View' to expected argument type 'String'
I am able to pass "circle" as an argument for systemImage, but not the image. Is there any way to change systemImage properties when a string is required?
CodePudding user response:
You can not take Image() in systemImage you can only pass string in that. if you want to change the color of the text and image then below code will work:
MenuBarExtra("label", systemImage:"circle").foregroundColor(.red)