article

Saturday, February 12, 2022

SwiftUI Pop Up Menu

SwiftUI Pop Up Menu

ContentView.swift
 
//
//  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