Updates the view’s content by modifying its underlying layer.
SDK
- macOS 10.8+
Framework
- App
Kit
Declaration
func updateLayer()
Discussion
You use this method to optimize the rendering of your view in situations where you can represent your views contents entirely using a layer object. If your view’s wants
property is true
, the view calls this method instead of draw(_:)
during the view update cycle. Custom views can override this method and use it to modify the properties of the underlying layer object. Modifying layer properties is a much more efficient way to update your view than is redrawing its content each time something changes.
When you want to update the contents of your layer, mark the view as dirty by setting its needs
property to true
. Doing so adds the view to the list of views that need to be refreshed during the next update cycle. During that update cycle, this method is called if thewants
property is still true
.
Your implementation of this method should not call super
.