Skip to content

Instantly share code, notes, and snippets.

@gf3
Last active August 14, 2019 14:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gf3/8fa3cf7c27c8312de8238d36859371ca to your computer and use it in GitHub Desktop.
Save gf3/8fa3cf7c27c8312de8238d36859371ca to your computer and use it in GitHub Desktop.
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