CALayerDelegate Informal Protocol Reference
| Framework | /System/Library/Frameworks/QuartzCore.framework |
| Declared in | CALayer.h |
| Companion guides |
Overview
The CALayerDelegate informal protocol is implemented by the layer’s delegate to respond to layer-related events. You can implement the methods of this protocol to provide the layer’s content, handle the layout of sublayers, and provide custom animation actions to perform. The object that implements this protocol must be assigned to the delegate property of the layer object.
Instance Methods
actionForLayer:forKey:
Asks the delegate for the specified action. (required)
Parameters
- layer
The layer that is the target of the action.
- key
The identifier of the action.
Return Value
An object implementing the CAAction protocol or nil if the delegate does not specify a behavior for the specified key.
Discussion
Your delegate object can implement this method when it wants to provide custom actions for a layer. For information about how layer-related actions are chosen, see the actionForKey: method of CALayer.
Availability
- Available in OS X v10.5 and later.
Declared In
CALayer.hdisplayLayer:
Asks the delegate to update the layer’s contents. (required)
Parameters
- layer
The layer whose contents need updating.
Discussion
The layer calls this method early in its update cycle to give your delegate a chance to set the layer’s contents property directly. If you do not implement this method, the layer calls the drawLayer:inContext: method instead.
Availability
- Available in OS X v10.5 and later.
Declared In
CALayer.hdrawLayer:inContext:
Asks the delegate to draw the layer’s contents. (required)
Parameters
- layer
The layer whose contents need to be drawn.
- ctx
The graphics context to use for drawing. The graphics context incorporates the appropriate scale factor for drawing to the target screen.
Discussion
If you do not want to set the contents of the layer directly using the displayLayer: method, you can implement this method and use it to draw the contents of your layer. You might prefer this method in cases where the layer’s content is already dynamic and must be regenerated.
The context may be clipped to protect valid layer content. Subclasses that wish to find the actual region to draw can call the CGContextGetClipBoundingBox function.
Availability
- Available in OS X v10.5 and later.
Declared In
CALayer.hlayoutSublayersOfLayer:
Asks the delegate to lay out the sublayers of the specified layer.
Parameters
- layer
The layer that requires layout of its sublayers.
Discussion
During a layout update, the layer calls this method to give your delegate a chance to adjust the position or size of any sublayers. Your delegate object is responsible for changing the frame of each sublayer that requires layout.
If you do not implement this method, the layer calls the layoutSublayersOfLayer: method on the object in the layer’s layoutManager property. If you do implement this method, the layer does not ask its layout manager object to update the layout.
Availability
- Available in OS X v10.5 and later.
Declared In
CALayer.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-12-13)