简体   繁体   English

增加SwiftUI中MenuBarExtra.menu按钮的高度/padding

[英]Increase the height / padding of the MenuBarExtra .menu button in SwiftUI

I've been frustrated for some time now trying to figure out how to increase the height of the button in the MenuBarExtra menu for a MacOS app.一段时间以来,我一直很沮丧,试图弄清楚如何增加 MacOS 应用程序 MenuBarExtra 菜单中按钮的高度。 I've seen another app that has a larger height on these buttons, but I've been unable to replicate the same style nor have I found anything similar on the web.我见过另一个应用程序在这些按钮上有更高的高度,但我无法复制相同的样式,也没有在 web 上找到任何类似的东西。

This is what I have so far.这是我到目前为止所拥有的。 Tried out applying different MenuBarExtraStyle to it, but what I need is a .menu style which is of a type PullDownMenuBarExtraStyle .尝试对其应用不同的MenuBarExtraStyle ,但我需要的是一种.menu样式,它属于PullDownMenuBarExtraStyle类型。

MenuBarExtra("Settings", systemImage: "hammer") {
     Button(action: {}) {
                HStack {
                    Image(systemName: "pawprint.fill")
                    Text("Small Button")
                }
            }
        }
        .menuBarExtraStyle(.menu)

If you switch to .menuBarExtraStyle(.window) you have full control over the display sizes and can build your own menu there.如果切换到.menuBarExtraStyle(.window) ,您可以完全控制显示尺寸,并可以在那里构建自己的菜单。

        MenuBarExtra("Settings", systemImage: "hammer") {
            VStack {
                Button(action: {}) {
                    Label("Larger Button", systemImage: "pawprint.fill")
                    .font(.largeTitle)
                }
                .buttonStyle(.plain)
                .padding()
            }
        }
        .menuBarExtraStyle(.window)

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

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