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
// This extension is a port of @venj's solution from 2011 | |
// https://github.com/venj/Cocoa-blog-code/blob/master/Round%20Corner%20Image/Round%20Corner%20Image/NSImage%2BRoundCorner.m | |
extension NSImage { | |
func roundCorners(withRadius radius: CGFloat) -> NSImage { | |
let rect = NSRect(origin: NSPoint.zero, size: size) | |
if | |
let cgImage = self.cgImage, | |
let context = CGContext(data: nil, |