如何在长按显示ContextMenu时更改内容的背景颜色?

这是ChatGPT在ContextMenu显示时,消息内容从透明背景切换为深灰色背景的示例。以下是实现代码:
struct ContentView: View { var body: some View { Text("Long press for menu") .background(.clear) .contextMenu { Button { print("Pills selected") } label: { Label("Pills", systemImage: "pills") } Button { print("Heart selected") } label: { Label("Heart rate", systemImage: "heart") } Button { print("ECG selected") } label: { Label("ECG", systemImage: "waveform.path.ecg") } } } }
内容的提问来源于stack exchange,提问作者artit
相关产品推荐
相关产品推荐

