Skip to content

Instantly share code, notes, and snippets.

@gf3
Last active Aug 14, 2019
Embed
What would you like to do?
NSImageView with rounded corners
// XCode 8.3
// Swift 3.1
import Cocoa
class SomeViewController: NSViewController {
@IBOutlet weak var artwork: NSImageView!
override func viewDidLoad() {
super.viewDidLoad()
artwork.wantsLayer = true // Use a layer as backing store for this view
artwork.canDrawSubviewsIntoLayer = true // Important, flatten all subviews into layer
artwork.layer?.cornerRadius = 4.0
artwork.layer?.masksToBounds = true // Mask layer
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment