Skip to content

Instantly share code, notes, and snippets.

@sfsam
Last active June 2, 2017 21:39
Show Gist options
  • Save sfsam/ac3d7faddf96743cb29bf011939902cb to your computer and use it in GitHub Desktop.
Save sfsam/ac3d7faddf96743cb29bf011939902cb to your computer and use it in GitHub Desktop.
// Regarding http://indiestack.com/2017/06/evergreen-images/
// Could evergreenImage() be rewritten like this?
private func evergreenImage() -> NSImage {
let imageSize = NSSize(width: 64, height: 64)
let image = NSImage.init(size: imageSize, flipped: false) { (rect) -> Bool in
let fontAttributes = [NSFontAttributeName: NSFont.systemFont(ofSize: 60)]
NSString(string: "🌲").draw(in: rect, withAttributes: fontAttributes)
return true
}
image.setName("NSApplicationIcon")
return image
}
func applicationDidFinishLaunching(_ note: Notification) {
NSApplication.shared().applicationIconImage = evergreenImage()
// Rest of applicationDidFinishLaunching() goes here...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment