Mac Developer Library

Developer

QuartzCore Framework Reference CALayoutManager Protocol Reference

Options
Deployment Target:

On This Page
Language:

CALayoutManager

CALayoutManager is an informal protocol implemented by Core Animation layout managers. If a layer’s sublayers require custom layout you create a class that implements this protocol and set it as the layer’s layout manager using the CALayer method setLayoutManager:. Your custom layout manager is then used when the layer invokes setNeedsLayout or layoutSublayers.

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import QuartzCore

Objective-C

@import QuartzCore;

Availability


Available in OS X v10.5 and later.
  • Invalidates the layout of the specified layer.

    Declaration

    Swift

    func invalidateLayoutOfLayer(_ layer: CALayer!)

    Objective-C

    - (void)invalidateLayoutOfLayer:(CALayer *)layer

    Parameters

    layer

    The layer that requires layout.

    Discussion

    This method is called when the preferred size of the specified layer may have changed. The receiver should invalidate any cached state.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Layout each of the sublayers in the specified layer.

    Declaration

    Swift

    func layoutSublayersOfLayer(_ layer: CALayer!)

    Objective-C

    - (void)layoutSublayersOfLayer:(CALayer *)layer

    Parameters

    layer

    The layer that requires layout of its sublayers.

    Discussion

    This method is called when the sublayers of the layer may need rearranging, and is typically called when a sublayer has changed its size. The receiver is responsible for changing the frame of each sublayer that requires layout.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.

  • Returns the preferred size of the specified layer in its coordinate system.

    Declaration

    Swift

    func preferredSizeOfLayer(_ layer: CALayer!) -> CGSize

    Objective-C

    - (CGSize)preferredSizeOfLayer:(CALayer *)layer

    Parameters

    layer

    The layer that requires layout.

    Return Value

    The preferred size of the layer in the coordinate space of layer.

    Discussion

    This method is called when the preferred size of the specified layer may have changed. The receiver is responsible for recomputing the preferred size and returning it. If this method is not implemented the preferred size is assumed to be the size of the bounds of layer.

    Import Statement

    Objective-C

    @import QuartzCore;

    Swift

    import QuartzCore

    Availability

    Available in OS X v10.5 and later.