I have the following `NSView` subclass, which is layer backed, and draws a `CAGradientLayer`. When I call `needsDisplay = true`, I'd expect `updateLayer` to be called, but it isn't. Is my understanding of what should happen incorrect, or have I done something wrong?
Thanks,
Luke
class ViewSubclass: NSView
{
override var wantsUpdateLayer: Bool
{
return true
}
init()
{
super.init(frame: CGRectZero)
self.wantsLayer = true
self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawPolicy.OnSetNeedsDisplay
}
required init?(coder: NSCoder)
{
fatalError("init(coder:) has not been implemented")
}
override func makeBackingLayer() -> CALayer
{
let saturationGradientLayer = CAGradientLayer()
saturationGradientLayer.colors = [NSColor.whiteColor().CGColor,
NSColor.redColor().CGColor]
saturationGradientLayer.locations = [0.0, 1.0]
saturationGradientLayer.startPoint = CGPoint(x: 0.0, y: 0.0)
saturationGradientLayer.endPoint = CGPoint(x: 1.0, y: 0.0)
return saturationGradientLayer
}
override func updateLayer()
{
NSLog("Update layer called")
}