I went through many topics here and on other blogs, but could not solve this problem. I have an extra view in the window contents window. Here is the storyboard -
-
I pulled the output from customView to view the controller and here is the code for the controller -
import Cocoa
import QuartzCore
class ViewController: NSViewController {
@IBOutlet weak var customView: NSView!
override func viewDidLoad() {
super.viewDidLoad()
self.view.wantsLayer = true
self.customView.wantsLayer = true
self.customView.layer?.backgroundColor = NSColor.redColor().CGColor
self.customView.layer?.cornerRadius = 5.0
self.customView.layer?.shadowOpacity = 1.0
self.customView.layer?.shadowColor = NSColor.blackColor().CGColor
self.customView.layer?.shadowOffset = NSMakeSize(0, -3)
self.customView.layer?.shadowRadius = 20
}
override var representedObject: AnyObject? {
didSet {
}
}
}
I added the QuartzCore framework to my project -

But the shadow does not appear, here is a screenshot
.
I can’t decide what seems trivial. What am I missing? thank you for your help.
source
share