Class: CALayer

Inherits:
NSObject show all

Overview

The CALayer class is the model class for layer-tree objects. It encapsulates the position, size, and transform of a layer, which defines its coordinate system. It also encapsulates the duration and pacing of a layer and its animations by adopting the CAMediaTiming protocol, which defines a layer’s time space.

Direct Known Subclasses

AVCaptureVideoPreviewLayer, AVPlayerLayer, AVSynchronizedLayer, CAEAGLLayer, CAEmitterLayer, CAGradientLayer, CAReplicatorLayer, CAScrollLayer, CAShapeLayer, CATextLayer, CATiledLayer, CATransformLayer

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Hash) actions

A dictionary mapping keys to objects that implement the CAAction protocol. The default value is nil. See actionForKey: for a description of the action search pattern.

Returns:

- (CGPoint) anchorPoint

Defines the anchor point of the layer’s bounds rectangle. Animatable. Described in the unit coordinate space. The value of this property is specified in points. Defaults to (0.5, 0.5), the center of the bounds rectangle.See “Layer Geometry and Transforms” in Core Animation Programming Guide for more information on the relationship between the bounds, anchorPoint and position properties.

Returns:

  • (CGPoint)

- (Float) anchorPointZ

The Z component of the layer's anchor point. Animatable. The anchorPointZ value is expressed as a distance along the Z axis. Defaults to 0.

Returns:

- (CGColorRef) backgroundColor

Specifies the background color of the receiver. Animatable. The default is nil.The value of this property is retained using the Core Foundation retain/release semantics. This behavior occurs despite the fact that the property declaration appears to use the default assign semantics for object retention.

Returns:

  • (CGColorRef)

- (Array) backgroundFilters

An optional array of CoreImage filters that are applied to the receiver’s background. Animatable. Once an array of filters is set properties should be modified by invoking setValue:forKeyPath: using the appropriate key path. This requires that you set the name of the background filter to be modified. For example: If the inputs of a background filter are directly modified after the filter is attached to a layer, the behavior is undefined.

Returns:

- (CGColorRef) borderColor

The color of the receiver’s border. Animatable. Defaults to opaque black.The value of this property is retained using the Core Foundation retain/release semantics. This behavior occurs despite the fact that the property declaration appears to use the default assign semantics for object retention.

Returns:

  • (CGColorRef)

- (Float) borderWidth

Specifies the width of the receiver’s border. Animatable. The border is drawn inset from the receiver’s bounds by borderWidth. It is composited above the receiver’s contents and sublayers and includes the effects of the cornerRadius property. The default is 0.0.

Returns:

- (CGRect) bounds

Specifies the bounds rectangle of the receiver. Animatable. The default is an empty rectangle. The value of this property is specified in points. See “Layer Geometry and Transforms” in Core Animation Programming Guide for more information on the relationship between the bounds, anchorPoint and position properties.

Returns:

- (Object) compositingFilter

A CoreImage filter used to composite the receiver’s contents with the background. Animatable. If nil, the contents are composited using source-over. The default value is nil. Once a filter is set its properties should be modified by invoking setValue:forKeyPath: using the appropriate key path. For example: If the inputs of the filter are modified directly after the filter is attached to a layer, the behavior is undefined.

Returns:

- (Object) contents

An object that provides the contents of the layer. Animatable. The default value of this property is nil. When this property is nil, the layer contents are rendered to a layer-managed backing store. You can set this property to a CGImageRef to present the contents of the image in place of the layer’s contents. (In OS X 10.6 and later, you can also set it to an NSImage object.) Assigning an image to this property replaces the layer’s own backing store with the image’s content.

Returns:

- (CGRect) contentsCenter

Specifies the area of the content image that should be scaled. Animatable. The rectangle is interpreted after the effects of the contentsRect property have been applied to the image.Defaults to the unit rectangle (0.0,0.0) (1.0,1.0) resulting in the entire image being scaled. If the rectangle extends outside the unit rectangle the result is undefined.When an image is resized due to its contentsGravity property, its center part implicitly defines the 3x3 grid that controls how the image is scaled to its drawn size. The center part is stretched in both dimensions; the top and bottom parts are only stretched horizontally; the left and right parts are only stretched vertically; the four corner parts are not stretched at all.Note: If the width or height of contentsCenter is 0, it is implicitly adjusted to the width or height of a single source pixel centered at that position.

Returns:

- (String) contentsGravity

Determines how the receiver’s contents are positioned within its bounds. The possible values for contentsGravity are shown in “Contents Gravity Values”. The default value is kCAGravityResize.

Returns:

- (CGRect) contentsRect

A rectangle, in the unit coordinate space, defining the sub-rectangle of contents that the receiver should draw. Animatable. Defaults to the unit rectangle (0.0, 0.0, 1.0, 1.0).If pixels outside the unit rectangles are requested, the edge pixels of the contents image will be extended outwards.If an empty rectangle is provided, the results are undefined.

Returns:

- (Float) contentsScale

The scale factor applied to the layer. This value defines the mapping between the logical coordinate space of the layer (measured in points) and the physical coordinate space (measured in pixels). Higher scale factors indicate that each point in the layer is represented by more than one pixel at render time. For example, if the scale factor is 2.0 and the layer’s bounds are 50 x 50 points, the size of the bitmap used to present the layer’s content is 100 x 100 pixels.The contentScale default value is 1.0. In certain restricted cases, the value may set the value to 2.0 on hi-dpi devices.You can change this value as needed to indicate to Core Animation that the bitmap of the backing layer needs to be bigger or smaller. For example, if you set the contents of the view directly, you can change the value to ensure that layer’s bitmap matches the size of the image you are using.

Returns:

- (Float) cornerRadius

Specifies a radius used to draw the rounded corners of the receiver’s background. Animatable. If the radius is greater than 0 the background is drawn with rounded corners. The default value is 0.0.

Returns:

- (Object) delegate

Specifies the receiver’s delegate object. In iOS, if the layer is associated with a UIView object, this property must be set to the view that owns the layer.

Returns:

- (Boolean) doubleSided

Determines whether the receiver is displayed when facing away from the viewer. Animatable. If NO, the layer is hidden when facing away from the viewer. Defaults to YES.

Returns:

  • (Boolean)

- (Boolean) drawsAsynchronously

A Boolean indicating whether drawing commands are deferred and processed asynchronously in a background thread. When this property is set to YES, the graphics context used for drawing may queue drawing commands rather than execute them synchronously. Queueing the commands and performing them later in a background thread can improve performance in some apps. However, you should always measure the actual performance benefits before committing to using this capability.The default value for this property is NO.

Returns:

  • (Boolean)

- (unsigned int) edgeAntialiasingMask

A bitmask defining how the edges of the receiver are rasterized. For each of the four edges (left, right, bottom, top) if the corresponding bit is set the edge will be antialiased.Typically, this property is used to disable antialiasing for edges that abut edges of other layers, to eliminate the seams that would otherwise occur.The mask values are defined in “Edge Antialiasing Mask.”

Returns:

  • (unsigned int)

- (Array) filters

An array of CoreImage filters that are applied to the contents of the receiver and its sublayers. Animatable. Defaults to nil. Filter properties should be modified by calling setValue:forKeyPath: on each layer that the filter is attached to. If the inputs of the filter are modified directly after the filter is attached to a layer, the behavior is undefined.

Returns:

- (CGRect) frame

Specifies receiver’s frame rectangle in the super-layer’s coordinate space. The value of frame is derived from the bounds, anchorPoint and position properties. When the frame is set, the receiver’s position and the size of the receiver’s bounds are changed to match the new frame rectangle. The value of this property is specified in points.See “Layer Geometry and Transforms” in Core Animation Programming Guide for more information on the relationship between the bounds, anchorPoint and position properties.Note: The frame property is not directly animatable. Instead you should animate the appropriate combination of the bounds, anchorPoint and position properties to achieve the desired result.

Returns:

- (Boolean) geometryFlipped

Determines if the geometry of the layer and its sublayers are flipped vertically. The value of this property does not effect the rendering of the layer’s content, the image specified by contents will display the same regardless of the value of geometryFlipped.Defaults to NO.

Returns:

  • (Boolean)

- (Boolean) hidden

Determines whether the receiver is displayed. Animatable. The default is NO.

Returns:

  • (Boolean)

- (String) magnificationFilter

The filter used when increasing the size of the content. The possible values for magnificationFilter are shown in “Scaling Filters”. The default value is kCAFilterLinear.

Returns:

- (CALayer) mask

An optional layer whose alpha channel is used as a mask to select between the layer's background and the result of compositing the layer's contents with its filtered background.

Defaults to nil.

Returns:

- (Boolean) masksToBounds

Determines if the sublayers are clipped to the receiver’s bounds. Animatable. If YES, an implicit mask matching the layer bounds is applied to the layer, including the effects of the cornerRadius property. If YES and a mask property is specified, the two masks are multiplied to get the actual mask values. Defaults to NO.

Returns:

  • (Boolean)

- (String) minificationFilter

The filter used when reducing the size of the content. The possible values for minificationFilter are shown in “Scaling Filters”. The default value is kCAFilterLinear.

Returns:

- (Float) minificationFilterBias

The bias factor used by the minification filter to determine the levels of detail. This value is used by the minificationFilter when it is set to kCAFilterTrilinear.Defaults to 0.

Returns:

- (String) name

The name of the receiver. The layer name is used by some layout managers to identify a layer. Defaults to nil.

Returns:

- (Boolean) needsDisplayOnBoundsChange

Returns whether the receiver must be redisplayed when the bounds rectangle is updated. When YES, setNeedsDisplay is automatically invoked when the receiver’s bounds is changed. Default value is NO.

Returns:

  • (Boolean)

- (Float) opacity

Determines the opacity of the receiver. Animatable. Possible values are between 0.0 (transparent) and 1.0 (opaque). The default is 1.0.

Returns:

- (Boolean) opaque

This property affects how the layer creates the content directly. Defaults to NO.Note that this property has no effect for images provided directly by the developer.This property only affects what happens if setNeedsDisplay is called, and then display creates a bitmap for the drawInContext: method to draw into. In that case whether the generated bitmap has an alpha channel is defined by the value of this property. This value has no effect for images provided directly by the developer in the contents property.

Returns:

  • (Boolean)

- (CGPoint) position

Specifies the receiver’s position in the superlayer’s coordinate system. Animatable. The position is relative to anchorPoint. The value of this property is specified in points. The default is (0.0, 0.0).See “Layer Geometry and Transforms” in Core Animation Programming Guide for more information on the relationship between the bounds, anchorPoint and position properties.

Returns:

  • (CGPoint)

- (Float) rasterizationScale

The scale at which to rasterize content, relative to the coordinate space of the layer. Animatable When the value in the shouldRasterize property is YES, the layer uses this property to determine whether to scale the rasterized content (and by how much). The default value of this property is 1.0, which indicates that the layer should be rasterized at its current size. Larger values magnify the content and smaller values shrink it.

Returns:

- (CGColorRef) shadowColor

Specifies the color of the receiver’s shadow. Animatable. The default is opaque black.The value of this property is retained using the Core Foundation retain/release semantics. This behavior occurs despite the fact that the property declaration appears to use the default assign semantics for object retention.

Returns:

  • (CGColorRef)

- (CGSize) shadowOffset

Specifies the offset of the receiver’s shadow. Animatable. The default is (0.0,-3.0).

Returns:

- (Float) shadowOpacity

Specifies the opacity of the receiver’s shadow. Animatable. The default is 0.0.

Returns:

- (CGPathRef) shadowPath

Defines the shape of the shadow. Animatable. Unlike most animatable properties, the shadowPath property (as with all CGPathRef animatable properties) does not support implicit animation. The path object may be animated using any of the concrete subclasses of CAPropertyAnimation. Paths will interpolate as a linear blend of the “on-line” points; “off-line” points may be interpolated non-linearly (e.g. to preserve continuity of the curve’s derivative). If the two paths have a different number of control points or segments the results are undefined. If the path extends outside the layer bounds it will not automatically be clipped to the layer, only if the normal layer masking rules cause that.If the value in this property is non-nil, the shadow is created using the specified path instead of the layer’s composited alpha channel. The path defines the outline of the shadow. It is filled using the non-zero winding rule and the current shadow color, opacity, and blur radius. Specifying an explicit path usually improves rendering performance.The default value of this property is NULL.The value of this property is retained using the Core Foundation retain/release semantics. This behavior occurs despite the fact that the property declaration appears to use the default assign semantics for object retention.

Returns:

  • (CGPathRef)

- (Float) shadowRadius

Specifies the blur radius used to render the receiver’s shadow. Animatable. The default value is 3.0.

Returns:

- (Boolean) shouldRasterize

A Boolean that indicates whether the layer is rendered as a bitmap before compositing. Animatable When the value of this property is YES, the layer is rendered as a bitmap in its local coordinate space and then composited to the destination with any other content. Shadow effects and any filters in the filters property are rasterized and included in the bitmap. However, the current opacity of the layer is not rasterized. If the rasterized bitmap requires scaling during compositing, the filters in the minificationFilter and magnificationFilter properties are applied as needed.When the value of this property is NO, the layer is composited directly into the destination whenever possible. The layer may still be rasterized prior to compositing if certain features of the compositing model (such as the inclusion of filters) require it. The default value of this property is NO.

Returns:

  • (Boolean)

- (Hash) style

An optional dictionary referenced to find property values that aren’t explicitly defined by the receiver. This dictionary may in turn have a style key, forming a hierarchy of default values. In the case of hierarchical style dictionaries the shallowest value for a property is used. For example, the value for “style.someValue” takes precedence over “style.style.someValue”.If the style dictionary doesn’t define a value for an attribute, the receiver’s defaultValueForKey: method is called. Defaults to nil.The style dictionary is not consulted for the following keys: bounds, frame.Warning: If the style dictionary or any of its ancestors are modified, the values of the layer’s properties are undefined until the style property is reset.

Returns:

- (Array) sublayers

An array containing the receiver's sublayers. The layers are listed in back to front order. Defaults to nil.

Returns:

- (CATransform3D) sublayerTransform

Specifies a transform applied to each sublayer when rendering. Animatable. This property is typically used as the projection matrix to add perspective and other viewing effects to the receiver. Defaults to the identity transform.

Returns:

  • (CATransform3D)

- (CALayer) superlayer (readonly)

Specifies receiver's superlayer. (read-only)

Returns:

- (CATransform3D) transform

Specifies the transform applied to the receiver, relative to the center of its bounds. Animatable. Defaults to the identity transform.

Returns:

  • (CATransform3D)

- (CGRect) visibleRect (readonly)

Returns the visible region of the receiver, in its own coordinate space. (read-only) The visible region is the area not clipped by the containing scroll layer.

Returns:

- (Float) zPosition

Specifies the receiver’s position on the z axis. Animatable. Defaults to 0.

Returns:

Class Method Details

+ (Object) defaultActionForKey(key)

Returns an object that implements the default action for the specified identifier. See actionForKey: for a description of the action search pattern.

Parameters:

  • key (String)

    The identifier of the action.

Returns:

  • (Object)

    Returns the object that provides the action for key.

+ (Object) defaultValueForKey(key)

Specifies the default value of the property with the specified key. If no explicit default value is registered, this method returns a suitable “zero” default value based on the expected value of the key. For example, if the value for key is a CGSize struct, the method returns a size struct containing (0.0,0.0) wrapped in an NSValue object. For a CGRect an empty rectangle is returned. For CGAffineTransform and CATransform3D, the appropriate identity matrix is returned.

Parameters:

  • key (String)

    The name of one of the receiver’s properties.

Returns:

  • (Object)

    The default value for the named property. Returns nil if no default value has been set.

+ (Object) layer

Creates and returns an instance of the layer object. Subclasses override this method to provide an instance of the specific subclass.

Returns:

  • (Object)

    The initialized layer object or nil if initialization was not successful.

+ (Boolean) needsDisplayForKey(key)

Returns whether changes to the specified key requires the layer to be redisplayed. Subclasses should override this method and return YES if the layer should be redisplayed when the value of the specified attribute changes. Animations changing the value of the attribute will also trigger redisplay. The default implementation returns NO.

Parameters:

  • key (String)

    A string that specifies an attribute of the layer.

Returns:

  • (Boolean)

    YES if the layer requires display.

Instance Method Details

- (Object) actionForKey(key)

Returns an object that implements the action for the specified identifier. There are three types of actions: property changes, externally-defined events, and layer-defined events. Whenever a layer property is modified, the event with the same name as the property is triggered. External events are defined by the owner of the layer calling actionForKey: to lookup the action associated with the identifier and directly messaging the returned object (if non-nil.)The default implementation searches for an action object as follows:Return the value NULL if the search should not continue.If defined, return the object provided by the receiver’s delegate method actionForLayer:forKey:.Return the object that corresponds to the identifier in the receiver’s actions dictionary property. If nil is returned their is no action specified for requested key.Search the style dictionary recursively for an actions dictionary that contains the identifier.Call the receiver’s defaultActionForKey: method and return the result.When an action object is invoked it receives three parameters: the name of the event, the object on which the event happened (the layer), and a dictionary of named arguments specific to each event kind.

Parameters:

  • key (String)

    The identifier of the action.

Returns:

  • (Object)

    Returns the object that provides the action for key. The object must implement the CAAction protocol.

- (Object) addAnimation(anim, forKey:key)

Add an animation object to the receiver’s render tree for the specified key. Typically this is implicitly invoked through an action that is an CAAnimation object. If the duration property of the animation is zero or negative it is given the default duration, either the current value of the kCATransactionAnimationDuration transaction property, otherwise .25 seconds

Parameters:

  • anim (CAAnimation)

    The animation to be added to the render tree. Note that the object is copied by the render tree, not referenced. Any subsequent modifications to the object will not be propagated into the render tree.

  • key (String)

    A string that specifies an identifier for the animation. Only one animation per unique key is added to the layer. The special key kCATransition is automatically used for transition animations. The nil pointer is also a valid key.

Returns:

- (Object) addSublayer(aLayer)

Appends the layer to the receiver’s sublayers array.

Parameters:

  • aLayer (CALayer)

    The layer to be added to the receiver’s sublayers array.

Returns:

- (CGAffineTransform) affineTransform

Convenience method for getting the transform property as an affine transform.

Returns:

- (CAAnimation) animationForKey(key)

Returns the animation added to the receiver with the specified identifier. Attempting to modify any properties of the returned object will result in undefined behavior.

Parameters:

  • key (String)

    A string that specifies the identifier of the animation.

Returns:

  • (CAAnimation)

    The animation object matching the identifier, or nil if no such animation exists.

- (Array) animationKeys

Returns an array containing the keys of all animations currently attached to the receiver. The order of the array matches the order in which animations will be applied.

Returns:

  • (Array)

    An array of NSString objects representing the layer’s animations.

- (Boolean) containsPoint(thePoint)

Returns whether the receiver contains a specified point.

Parameters:

  • thePoint (CGPoint)

    A point in the receiver’s coordinate system.

Returns:

  • (Boolean)

    YES if the bounds of the layer contains the point.

- (Boolean) contentsAreFlipped

Returns whether the layer content is implicitly flipped when rendered. When this method returns YES the CGContextRef object passed to drawInContext: by the default display method will have been y- flipped and rectangles passed to setNeedsDisplayInRect: will be similarly flipped.Defaults to NO.Subclasses should not attempt to redefine this method.

Returns:

  • (Boolean)

    YES if the layer contents are implicitly flipped when rendered.

- (CGPoint) convertPoint(aPoint, fromLayer:layer)

Converts the point from the specified layer’s coordinate system to the receiver’s coordinate system. If you specify nil for the layer parameter, this method returns the original point.

Parameters:

  • aPoint (CGPoint)

    A point specifying a location in the coordinate system of layer.

  • layer (CALayer)

    The layer with aPoint in its coordinate system. The receiver and layer and must share a common parent layer. This parameter may be nil.

Returns:

  • (CGPoint)

    The point converted to the receiver’s coordinate system.

- (CGPoint) convertPoint(aPoint, toLayer:layer)

Converts the point from the receiver’s coordinate system to the specified layer’s coordinate system.

Parameters:

  • aPoint (CGPoint)

    A point specifying a location in the coordinate system of layer.

  • layer (CALayer)

    The layer into whose coordinate system aPoint is to be converted. The receiver and layer must share a common parent layer.

Returns:

  • (CGPoint)

    The point converted to the coordinate system of layer.

- (CGRect) convertRect(aRect, fromLayer:layer)

Converts the rectangle from the specified layer’s coordinate system to the receiver’s coordinate system.

Parameters:

  • aRect (CGRect)

    A point specifying a location in the coordinate system of layer.

  • layer (CALayer)

    The layer with aRect in its coordinate system. The receiver and layer and must share a common parent layer.

Returns:

  • (CGRect)

    The rectangle converted to the receiver’s coordinate system.

- (CGRect) convertRect(aRect, toLayer:layer)

Converts the rectangle from the receiver’s coordinate system to the specified layer’s coordinate system.

Parameters:

  • aRect (CGRect)

    A point specifying a location in the coordinate system of layer.

  • layer (CALayer)

    The layer into whose coordinate system aRect is to be converted. The receiver and layer and must share a common parent layer.

Returns:

  • (CGRect)

    The rectangle converted to the coordinate system of layer.

- (CFTimeInterval) convertTime(timeInterval, fromLayer:layer)

Converts the time interval from the specified layer’s time space to the receiver’s time space.

Parameters:

  • timeInterval (CFTimeInterval)

    A point specifying a location in the coordinate system of layer.

  • layer (CALayer)

    The layer with timeInterval in its time space. The receiver and layer and must share a common parent layer.

Returns:

  • (CFTimeInterval)

    The time interval converted to the receiver’s time space.

- (CFTimeInterval) convertTime(timeInterval, toLayer:layer)

Converts the time interval from the receiver’s time space to the specified layer’s time space

Parameters:

  • timeInterval (CFTimeInterval)

    A point specifying a location in the coordinate system of layer.

  • layer (CALayer)

    The layer into whose time space timeInterval is to be converted. The receiver and layer and must share a common parent layer.

Returns:

  • (CFTimeInterval)

    The time interval converted to the time space of layer.

- (Object) display

Reload the content of this layer. Calls the drawInContext: method, then updates the receiver’s contents property. You should not call this method directly.Subclasses can override this method to set the contents property to an appropriate CGImageRef.

Returns:

- (Object) displayIfNeeded

Displays the layer if it has been marked as needing display. When this message is received the layer will invoke display if it has been marked as requiring display.

Returns:

- (Object) drawInContext(ctx)

Draws the receiver’s content in the specified graphics context. The default implementation of this method does not doing any drawing itself. Subclasses can override this method to draw the layer’s content. When drawing, all coordinates should be specified in points in the logical coordinate space.If the method is not overridden and the layer has an associated delegate object, this method calls the delegate’s drawLayer:inContext: method to handle drawing.The context may be clipped to protect valid layer content. Subclasses that wish to find the actual region to draw can call CGContextGetClipBoundingBox.

Parameters:

  • ctx (CGContextRef)

    The graphics context in which to draw the content.

Returns:

- (CALayer) hitTest(thePoint)

Returns the farthest descendant of the receiver in the layer hierarchy (including itself) that contains a specified point.

Parameters:

  • thePoint (CGPoint)

    A point in the coordinate system of the receiver’s superlayer.

Returns:

  • (CALayer)

    The layer that contains thePoint, or nil if the point lies outside the receiver’s bounds rectangle.

- (Object) init

Returns an initialized CALayer object. This is the designated initializer for layer objects that are not in the presentation layer.

Returns:

- (Object) initWithLayer(layer)

Override to copy or initialize custom fields of the specified layer. This initializer is used to create shadow copies of layers, for example, for the presentationLayer method. Using this method in any other situation will produce undefined behavior. For example, do not use this method to initialize a new layer with an existing layer’s content.If you are implementing a custom layer subclass, you can override this method and use it to copy the values of instance variables into the new object. Subclasses should always invoke the superclass implementation. This method is the designated initializer for layer objects in the presentation layer.

Parameters:

  • layer (Object)

    The layer from which custom fields should be copied.

Returns:

  • (Object)

    A layer instance with any custom instance variables copied from layer.

- (Object) insertSublayer(aLayer, above:sublayer)

Inserts the layer into the receiver’s sublayers array, above the specified sublayer.

Parameters:

  • aLayer (CALayer)

    The layer to be inserted to the receiver’s sublayer array.

  • sublayer (CALayer)

    An existing sublayer in the receiver to insert aLayer above.

Returns:

- (Object) insertSublayer(aLayer, atIndex:index)

Inserts the layer as a sublayer of the receiver at the specified index.

Parameters:

  • aLayer (CALayer)

    The layer to be inserted to the receiver’s sublayer array.

  • index (unsigned)

    The index in the receiver at which to insert aLayer. This value must not be greater than the count of elements in the sublayer array.

Returns:

- (Object) insertSublayer(aLayer, below:sublayer)

Inserts the layer into the receiver’s sublayers array, below the specified sublayer. If sublayer is not in the receiver’s sublayers array, an exception is raised.

Parameters:

  • aLayer (CALayer)

    The layer to be inserted to the receiver’s sublayer array.

  • sublayer (CALayer)

    An existing sublayer in the receiver to insert aLayer after.

Returns:

- (Object) layoutIfNeeded

Recalculate the receiver’s layout, if required. When this message is received, the layer’s super layers are traversed until a ancestor layer is found that does not require layout. Then layout is performed on the entire layer-tree beneath that ancestor.

Returns:

- (Object) layoutSublayers

Called when the layer requires layout. The default implementation invokes the layout manager method layoutSublayersOfLayer:, if a layout manager is specified and it implements that method. Subclasses can override this method to provide their own layout algorithm, which must set the frame of each sublayer.

Returns:

- (Object) modelLayer

Returns the model layer of the receiver, if it represents a current presentation layer. Call this method while a transaction that involves changes to the presentation layer objects is in progress. Calling this method after the transaction has completed is undefined.

Returns:

  • (Object)

    A layer instance representing the underlying model layer.

- (Boolean) needsDisplay

Returns whether the layer has been marked as requiring display.

Returns:

  • (Boolean)

    YES if the layer has been marked as requiring display.

- (Boolean) needsLayout

Returns whether the layer has been marked as requiring layout.

Returns:

  • (Boolean)

    YES if the layer has been marked as requiring layout.

- (CGSize) preferredFrameSize

Returns the preferred frame size of the layer in the coordinate space of the superlayer. The default implementation calls the layout manager, if one exists and it implements the preferredSizeOfLayer: method. Otherwise, it returns the size of the receiver’s bounds rectangle mapped into coordinate space of the receiver’s superlayer.

Returns:

  • (CGSize)

    Returns the receiver’s preferred frame size.

- (Object) presentationLayer

Returns a copy of the layer containing all properties as they were at the start of the current transaction, with any active animations applied. This method provides a close approximation to the version of the layer that is currently being displayed. The sublayers, mask, and superlayer properties of the returned layer return the presentation versions of these properties. This pattern carries through to the read-only layer methods. For example, sending a hitTest: message to the presentationLayer will query the presentation values of the layer tree.

Returns:

  • (Object)

    A layer instance representing the current presentation layer.

- (Object) removeAllAnimations

Remove all animations attached to the receiver.

Returns:

- (Object) removeAnimationForKey(key)

Remove the animation attached to the receiver with the specified key.

Parameters:

  • key (String)

    The identifier of the animation to remove.

Returns:

- (Object) removeFromSuperlayer

Removes the layer from the sublayers array or mask property of the receiver’s superlayer.

Returns:

- (Object) renderInContext(ctx)

Renders the receiver and its sublayers into the specified context. This method renders directly from the layer tree, ignoring any animations added to the render tree. Renders in the coordinate space of the layer.Important: The OS X v10.5 implementation of this method does not support the entire Core Animation composition model. QCCompositionLayer, CAOpenGLLayer, and QTMovieLayer layers are not rendered. Additionally, layers that use 3D transforms are not rendered, nor are layers that specify backgroundFilters, filters, compositingFilter, or a mask values. Future versions of OS X may add support for rendering these layers and properties.

Parameters:

  • ctx (CGContextRef)

    The graphics context that the content is rendered in to.

Returns:

- (Object) replaceSublayer(oldLayer, with:newLayer)

Replaces the layer in the receiver’s sublayers array with the specified new layer. If the receiver is not the superlayer of oldLayer the behavior is undefined.

Parameters:

  • oldLayer (CALayer)

    The layer to be replaced to the receiver’s sublayer array.

  • newLayer (CALayer)

    The layer with which to replace oldLayer in the receiver’s sublayer array.

Returns:

- (Object) scrollPoint(thePoint)

Scrolls the receiver’s closest ancestor CAScrollLayer so that the specified point lies at the origin of the layer.

Parameters:

  • thePoint (CGPoint)

    The point in the receiver to scroll to.

Returns:

- (Object) scrollRectToVisible(theRect)

Scrolls the receiver’s closest ancestor CAScrollLayer the minimum distance needed so that the specified rectangle becomes visible.

Parameters:

  • theRect (CGRect)

    The rectangle to be made visible.

Returns:

- (Object) setAffineTransform(m)

Convenience method for setting the transform property as an affine transform.

Parameters:

Returns:

- (Object) setNeedsDisplay

Marks the receiver as needing display before the content is next committed. Calling this method will cause the receiver to recache its content. This will result in the layer receiving a drawInContext: which may result in the delegate receiving either a displayLayer: or drawLayer:inContext: message.

Returns:

- (Object) setNeedsDisplayInRect(theRect)

Marks the region of the receiver within the specified rectangle as needing display.

Parameters:

  • theRect (CGRect)

    The rectangular region of the receiver to mark as invalid; it should be specified in the coordinate system of the receiver.

Returns:

- (Object) setNeedsLayout

Called when the preferred size of the receiver may have changed. This method is typically called when the receiver’s sublayers have changed. It marks that the receiver sublayers must update their layout (by invoking layoutSublayers on the receiver and all its super layers). In OS X, if the receiver’s layout manager implements the invalidateLayoutOfLayer: method, it is called.

Returns:

- (Boolean) shouldArchiveValueForKey(key)

Specifies whether the value of the property for a given key is archived. The default implementation returns YES. Called by the object's implementation of encodeWithCoder:.

Parameters:

  • key (String)

    The name of one of the receiver’s properties.

Returns:

  • (Boolean)

    YES if the specified property should be archived, otherwise NO.