Last active
October 30, 2016 15:34
-
-
Save n3tr/e8a7762df56b86e81c8587e801d7e023 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension WindowController: NSTouchBarDelegate { | |
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItemIdentifier) -> NSTouchBarItem? { | |
switch identifier { | |
case NSTouchBarItemIdentifier.label: | |
// Create custom touch bar Item | |
let custom = NSCustomTouchBarItem(identifier: identifier) | |
custom.customizationLabel = "Label Title" | |
// Create label as NSTextField | |
let label = NSTextField(labelWithString: "Hello, TouchBar") | |
label.textColor = NSColor.green | |
// Assign custom item's view | |
custom.view = label | |
return custom | |
default: | |
return nil | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment