Reputation: 211
In the Interfacebuilder, NSImagebutton offers a wide range of system images to pick (see screenshot). I fail to change these images at runtime under MacOS. Under iOS there is UIImage with UIImage(systemName: "imageName")
but MacOS seems to offer nothing comparable?
Upvotes: 0
Views: 635
Reputation: 1670
As of XCode 15.4: If you are looking to set the image to one of XCode's own image icons you can use the following... this snippet sets an NSButton image to the system image named "magicmouse":
myButton.image = NSImage(systemSymbolName: "magicmouse", accessibilityDescription: nil)
For a list of system images and their names you can view the storyboard, select your button and in the Attributes Inspector click the drop-down next to the "Image" field. What you should see listed are pre-defined System images and their names.
Upvotes: 0
Reputation: 285074
It's quite similar in macOS for example
button.image = NSImage(named: NSImage.touchBarQuickLookTemplateName)
Upvotes: 1