Last active
August 14, 2019 14:43
-
-
Save gf3/8fa3cf7c27c8312de8238d36859371ca to your computer and use it in GitHub Desktop.
NSImageView with rounded corners
This file contains 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
// 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