macosswiftuinspopover

How to increase the icon button of Menu in MacOS App SwiftUI?


I want to increase the icon button of the Menu in SwiftUI for a macOS app, but modifiers such as .imageScale(.large), .resizable(), .scaleEffect(1.2), and changing font doesn't work. image

Menu {
    Button("Quit") {}
} label: {
    Image(systemName: "gear")
        .font(.title)
        .resizable()
        .scaleEffect(1.2)
        .imageScale(.large)
}
.menuStyle(.borderlessButton)
.menuIndicator(.hidden)

How can I change icon size?


Solution

  • Use ImageinText.

    struct DetailView: View {
        var body: some View {
            Text("hello")
                .contextMenu {
                    Button(action: { }) {
                        Text(Image(systemName: "gear"))
                            .font(.largeTitle)
                    }
                    
                    Button(action: { }) {
                        Image(systemName: "gear")
                    }
                }
        }
    }