【发布时间】:2020-08-14 11:14:48
【问题描述】:
Context menu background not updated
我正在尝试更新背景颜色。
视图的背景颜色已更新,但上下文菜单的背景颜色未更新
上下文菜单显示之前设置的颜色。
谁能帮我解决这个问题。 提前致谢
这是我使用的代码
import SwiftUI
struct ContextMenu: View {
/*List of items =*/
@State var bgColor = Color.gray
var body: some View {
HStack {
Rectangle().frame(width: 120, height: 120).opacity(0.01).border(Color.black, width: 1).contextMenu{
VStack {
Button("Orange",action: {
self.bgColor = Color.orange
})
Button("Green",action: {
self.bgColor = Color.green
})
Button("Red",action: {
self.bgColor = Color.red
})
}
}
}.frame(width:UIScreen.main.bounds.width, height: 200).background(bgColor)
}
}
【问题讨论】:
标签: background swiftui contextmenu