提问人:bulletproof software engineer 提问时间:9/6/2023 更新时间:9/10/2023 访问量:101
如何增加 NSStatusBar 图像大小?
How can I increase the NSStatusBar Image size?
问:
我注意到,无论我使用哪种图像,图像大小都比 macOS 菜单栏中的其他应用程序图像小一点。
这是我在 cocoa 中使用的代码:
private lazy var statusItem: NSStatusItem = NSStatusItem()
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
if let button = statusItem.button {
button.image = NSImage(systemSymbolName: "wifi", accessibilityDescription: "1")
}
如何使我的图像大小与其他应用程序相同?
结果:
答:
3赞
apodidae
9/6/2023
#1
以下源代码应使图标变大,但可能太大。您可以在此处阅读有关它的信息:NSImageSymbolConfiguration
// globals at top of AppDelegate
var statusItem: NSStatusItem!
var image: NSImage!
// Then in func applicationDidFinishLaunching()
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
if let button = statusItem.button {
image = NSImage(systemSymbolName: "wifi", accessibilityDescription: "1");
let config = NSImage.SymbolConfiguration(scale: .large)
button.image = image.withSymbolConfiguration(config)
}
评论
0赞
bulletproof software engineer
9/6/2023
我认为它对结果没有尊重。
0赞
apodidae
9/6/2023
它显然更大。请参阅编辑后的答案。
评论
NSStatusItem.variableLength
22
withLength
NSStatusItem.variableLength