ios – How to change the background color of the content when is long pressed and is showing the contextMenu?


enter image description here

This is just an example of how ChatGPT transitions from a clear background to a dark gray background for the content of the message when contextMenu is visible. Here are my codes:

 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")
                }
            }
    }

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img