Mac Developer Library

Developer

AppKit Framework Reference NSLayerDelegateContentsScaleUpdating Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSLayerDelegateContentsScaleUpdating

This protocol defines an optional CALayer delegate method for handling resolution changes, allowing you to manage scale and contents for a layer hosted in a view. More...

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.7 and later.
  • Invoked when a resolution changes occurs for the window that hosts the layer.

    Declaration

    Swift

    func layer(_ layer: CALayer, shouldInheritContentsScale newScale: CGFloat, fromWindow window: NSWindow) -> Bool

    Objective-C

    - (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window

    Parameters

    layer

    The layer whose scale and content might need updating.

    newScale

    The new scale of the window.

    window

    The window that hosts the layer.

    Return Value

    A Boolean value that specifies whether to change the layer’s contentsScale property.

    Discussion

    When a resolution change occurs for a given window, the system traverses the layer trees in that window to decide what action, if any, to take for each layer. The system will query the layer’s delegate to determine whether to change the layer’s contentsScale property to the new scale (either 2.0 or 1.0).

    If the delegate returns YEStrue, it should make any corresponding changes to the layer’s properties, as required by the resolution change. For example, a layer whose contents contain a CGImage object needs to determine whether an alternate CGImage object is available for the new scale factor. If the delegate finds a suitable CGImage object, then in addition to returning YEStrue, it should set the appropriate CGImage object as the layer’s new contents.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.7 and later.