article

Saturday, February 12, 2022

SwiftUI Pop Up Menu

SwiftUI Pop Up Menu

ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
//  ContentView.swift
//  swiftuidev15ios
//
//  Created by Cairocoders
//
 
import SwiftUI
 
struct ContentView: View {
    var body: some View {
        Menu {
            Button("Cancel", role: .destructive) {
                print("Cancel")
            }
             
            Menu {
                Button(role: .destructive) {
                    print("Report")
                } label: {
                    Label("Report", systemImage: "flag.fill")
                }
            } label: {
                Label("Other", systemImage: "questionmark.circle")
            }
             
            Button {
                print("Download")
            } label: {
                Label("Download", systemImage: "tray.and.arrow.down.fill")
            }
             
            Button {
                print("Share")
            } label: {
                Label("Share", systemImage: "square.and.arrow.up")
            }
        } label: {
            Label("Settings", systemImage: "gearshape.fill")
        }
         
    }
}
 
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Related Post