Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
extension Image {
/**
```
Image(nsImageNamed: NSImage.addTemplateName)
```
- Note: The `size` parameter is there as resizing in SwiftUI creates a blurry image. Seems like a bug:
```
Image(nsImageNamed: NSImage.addTemplateName)
.resizable()
.frame(width: 100, height: 100)
```
*/
init(nsImageNamed: NSImage.Name, size: CGSize? = nil) {
let image = NSImage(named: nsImageNamed)!
if let size = size {
image.size = size
}
self.init(nsImage: image)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment