1
隨着MacOS的塞拉利昂的容積菜單欄項目提供了一個水平滑塊項目更改系統的音量:如何放置水平滑塊在NSMenu(SWIFT 3,Xcode中8)
我想採用這個概念爲我自己的應用程序,並提出了以下類:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
let statusItem = NSStatusBar.system().statusItem(withLength: -2)
func applicationDidFinishLaunching(_ aNotification: Notification) {
let menu = NSMenu()
let menuItem = NSMenuItem()
let statusSlider = NSSlider()
menu.addItem(NSMenuItem(title: "Slider:", action: nil, keyEquivalent: ""))
menuItem.title = "Slider 1"
menuItem.view = statusSlider
menu.addItem(menuItem)
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(title: "Quit", action: Selector("terminate:"), keyEquivalent: "q"))
statusItem.image = NSImage(named: "NSStatusAvailable")
statusItem.menu = menu
}
}
但是沒有滑塊顯示在菜單中。有沒有人知道我做錯了什麼?
非常感謝:) – Zahlex
我終於能夠在指定幀大小後在我的菜單中獲得NSColorWell。 – samael