简体   繁体   English

如何在 MacOS App SwiftUI 中增加菜单的图标按钮?

[英]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.我想为 macOS 应用程序增加 SwiftUI 中Menu的图标按钮,但.imageScale(.large).resizable().scaleEffect(1.2)等修饰符和更改font不起作用。 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?如何更改图标大小?

Use Image in Text .Text中使用Image

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM