Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI contextMenu - how add red (dangerous) actions [duplicate]

This is a simple contextMenu. 1) How can I set Text("delete") and Image red.

2) How add divider (image below)

enter image description here

struct customMenu: View {

    var onDelete: (() -> Void)? 

    init(onDelete: @escaping () -> Void) {
        self.onDelete = onDelete;
    }

    var body: some View {
        VStack {
            if (self.onDelete != nil) {
                Button(action: self.onDelete!) {
                    HStack {
                        Text("delete") 
                        Image(systemName: "trash") 
                    }
                }
            }
        }
    }
}
like image 767
Tim Avatar asked Nov 11 '19 14:11

Tim


1 Answers

Very simple, just enter the following:

Divider()
like image 103
Gioser Avatar answered Nov 07 '22 17:11

Gioser