---
title: CALayer
framework: quartzcore
role: symbol
role_heading: Class
path: quartzcore/calayer
---

# CALayer

An object that manages image-based content and allows you to perform animations on that content.

## Declaration

```swift
class CALayer
```

## Overview

Overview Layers are often used to provide the backing store for views but can also be used without a view to display content. A layer’s main job is to manage the visual content that you provide but the layer itself has visual attributes that can be set, such as a background color, border, and shadow. In addition to managing visual content, the layer also maintains information about the geometry of its content (such as its position, size, and transform) that is used to present that content onscreen. Modifying the properties of the layer is how you initiate animations on the layer’s content or geometry. A layer object encapsulates the duration and pacing of a layer and its animations by adopting the CAMediaTiming protocol, which defines the layer’s timing information. If the layer object was created by a view, the view typically assigns itself as the layer’s delegate automatically, and you should not change that relationship. For layers you create yourself, you can assign a delegate object and use that object to provide the contents of the layer dynamically and perform other tasks. A layer may also have a layout manager object (assigned to the layoutManager property) to manage the layout of subviews separately.

## Topics

### Creating a layer

- [init()](quartzcore/calayer/init().md)
- [init(layer:)](quartzcore/calayer/init(layer:).md)
- [init(remoteClientId:)](quartzcore/calayer/init(remoteclientid:).md)

### Accessing related layer objects

- [presentation()](quartzcore/calayer/presentation().md)
- [model()](quartzcore/calayer/model().md)

### Accessing the delegate

- [delegate](quartzcore/calayer/delegate.md)

### Providing the layer’s content

- [contents](quartzcore/calayer/contents.md)
- [contentsRect](quartzcore/calayer/contentsrect.md)
- [contentsCenter](quartzcore/calayer/contentscenter.md)
- [display()](quartzcore/calayer/display().md)
- [draw(in:)](quartzcore/calayer/draw(in:).md)

### Modifying the layer’s appearance

- [contentsGravity](quartzcore/calayer/contentsgravity.md)
- [Contents Gravity Values](quartzcore/contents-gravity-values.md)
- [opacity](quartzcore/calayer/opacity.md)
- [isHidden](quartzcore/calayer/ishidden.md)
- [masksToBounds](quartzcore/calayer/maskstobounds.md)
- [mask](quartzcore/calayer/mask.md)
- [isDoubleSided](quartzcore/calayer/isdoublesided.md)
- [cornerRadius](quartzcore/calayer/cornerradius.md)
- [maskedCorners](quartzcore/calayer/maskedcorners.md)
- [CACornerMask](quartzcore/cacornermask.md)
- [borderWidth](quartzcore/calayer/borderwidth.md)
- [borderColor](quartzcore/calayer/bordercolor.md)
- [backgroundColor](quartzcore/calayer/backgroundcolor.md)
- [shadowOpacity](quartzcore/calayer/shadowopacity.md)
- [shadowRadius](quartzcore/calayer/shadowradius.md)
- [shadowOffset](quartzcore/calayer/shadowoffset.md)
- [shadowColor](quartzcore/calayer/shadowcolor.md)
- [shadowPath](quartzcore/calayer/shadowpath.md)
- [style](quartzcore/calayer/style.md)
- [allowsEdgeAntialiasing](quartzcore/calayer/allowsedgeantialiasing.md)
- [allowsGroupOpacity](quartzcore/calayer/allowsgroupopacity.md)

### Layer filters

- [filters](quartzcore/calayer/filters.md)
- [compositingFilter](quartzcore/calayer/compositingfilter.md)
- [backgroundFilters](quartzcore/calayer/backgroundfilters.md)
- [minificationFilter](quartzcore/calayer/minificationfilter.md)
- [minificationFilterBias](quartzcore/calayer/minificationfilterbias.md)
- [magnificationFilter](quartzcore/calayer/magnificationfilter.md)

### Configuring the layer’s rendering behavior

- [isOpaque](quartzcore/calayer/isopaque.md)
- [edgeAntialiasingMask](quartzcore/calayer/edgeantialiasingmask.md)
- [contentsAreFlipped()](quartzcore/calayer/contentsareflipped().md)
- [isGeometryFlipped](quartzcore/calayer/isgeometryflipped.md)
- [drawsAsynchronously](quartzcore/calayer/drawsasynchronously.md)
- [shouldRasterize](quartzcore/calayer/shouldrasterize.md)
- [rasterizationScale](quartzcore/calayer/rasterizationscale.md)
- [contentsFormat](quartzcore/calayer/contentsformat.md)
- [render(in:)](quartzcore/calayer/render(in:).md)

### Modifying the layer geometry

- [frame](quartzcore/calayer/frame.md)
- [bounds](quartzcore/calayer/bounds.md)
- [position](quartzcore/calayer/position.md)
- [zPosition](quartzcore/calayer/zposition.md)
- [anchorPointZ](quartzcore/calayer/anchorpointz.md)
- [anchorPoint](quartzcore/calayer/anchorpoint.md)
- [contentsScale](quartzcore/calayer/contentsscale.md)

### Managing the layer’s transform

- [transform](quartzcore/calayer/transform.md)
- [sublayerTransform](quartzcore/calayer/sublayertransform.md)
- [affineTransform()](quartzcore/calayer/affinetransform().md)
- [setAffineTransform(_:)](quartzcore/calayer/setaffinetransform(_:).md)

### Managing the layer hierarchy

- [sublayers](quartzcore/calayer/sublayers.md)
- [superlayer](quartzcore/calayer/superlayer.md)
- [addSublayer(_:)](quartzcore/calayer/addsublayer(_:).md)
- [removeFromSuperlayer()](quartzcore/calayer/removefromsuperlayer().md)
- [insertSublayer(_:at:)](quartzcore/calayer/insertsublayer(_:at:).md)
- [insertSublayer(_:below:)](quartzcore/calayer/insertsublayer(_:below:).md)
- [insertSublayer(_:above:)](quartzcore/calayer/insertsublayer(_:above:).md)
- [replaceSublayer(_:with:)](quartzcore/calayer/replacesublayer(_:with:).md)

### Updating layer display

- [setNeedsDisplay()](quartzcore/calayer/setneedsdisplay().md)
- [setNeedsDisplay(_:)](quartzcore/calayer/setneedsdisplay(_:).md)
- [needsDisplayOnBoundsChange](quartzcore/calayer/needsdisplayonboundschange.md)
- [displayIfNeeded()](quartzcore/calayer/displayifneeded().md)
- [needsDisplay()](quartzcore/calayer/needsdisplay().md)
- [needsDisplay(forKey:)](quartzcore/calayer/needsdisplay(forkey:).md)

### Layer animations

- [add(_:forKey:)](quartzcore/calayer/add(_:forkey:).md)
- [animation(forKey:)](quartzcore/calayer/animation(forkey:).md)
- [removeAllAnimations()](quartzcore/calayer/removeallanimations().md)
- [removeAnimation(forKey:)](quartzcore/calayer/removeanimation(forkey:).md)
- [animationKeys()](quartzcore/calayer/animationkeys().md)

### Managing layer resizing and layout

- [layoutManager](quartzcore/calayer/layoutmanager.md)
- [setNeedsLayout()](quartzcore/calayer/setneedslayout().md)
- [layoutSublayers()](quartzcore/calayer/layoutsublayers().md)
- [layoutIfNeeded()](quartzcore/calayer/layoutifneeded().md)
- [needsLayout()](quartzcore/calayer/needslayout().md)
- [autoresizingMask](quartzcore/calayer/autoresizingmask.md)
- [resize(withOldSuperlayerSize:)](quartzcore/calayer/resize(witholdsuperlayersize:).md)
- [resizeSublayers(withOldSize:)](quartzcore/calayer/resizesublayers(witholdsize:).md)
- [preferredFrameSize()](quartzcore/calayer/preferredframesize().md)

### Managing layer constraints

- [constraints](quartzcore/calayer/constraints.md)
- [addConstraint(_:)](quartzcore/calayer/addconstraint(_:).md)

### Getting the layer’s actions

- [action(forKey:)](quartzcore/calayer/action(forkey:).md)
- [actions](quartzcore/calayer/actions.md)
- [defaultAction(forKey:)](quartzcore/calayer/defaultaction(forkey:).md)

### Mapping between coordinate and time spaces

- [convert(_:from:)](quartzcore/calayer/convert(_:from:)-8kl76.md)
- [convert(_:to:)](quartzcore/calayer/convert(_:to:)-7dcke.md)
- [convert(_:from:)](quartzcore/calayer/convert(_:from:)-4kx9l.md)
- [convert(_:to:)](quartzcore/calayer/convert(_:to:)-tly5.md)
- [convertTime(_:from:)](quartzcore/calayer/converttime(_:from:).md)
- [convertTime(_:to:)](quartzcore/calayer/converttime(_:to:).md)

### Hit testing

- [hitTest(_:)](quartzcore/calayer/hittest(_:).md)
- [contains(_:)](quartzcore/calayer/contains(_:).md)

### Scrolling

- [visibleRect](quartzcore/calayer/visiblerect.md)
- [scroll(_:)](quartzcore/calayer/scroll(_:).md)
- [scrollRectToVisible(_:)](quartzcore/calayer/scrollrecttovisible(_:).md)

### Identifying the layer

- [name](quartzcore/calayer/name.md)

### Key-value coding extensions

- [shouldArchiveValue(forKey:)](quartzcore/calayer/shouldarchivevalue(forkey:).md)
- [defaultValue(forKey:)](quartzcore/calayer/defaultvalue(forkey:).md)

### High dynamic range

- [preferredDynamicRange](quartzcore/calayer/preferreddynamicrange.md)
- [contentsHeadroom](quartzcore/calayer/contentsheadroom.md)
- [wantsExtendedDynamicRangeContent](quartzcore/calayer/wantsextendeddynamicrangecontent.md)

### Constants

- [CAAutoresizingMask](quartzcore/caautoresizingmask.md)
- [Action Identifiers](quartzcore/action-identifiers.md)
- [CAEdgeAntialiasingMask](quartzcore/caedgeantialiasingmask.md)
- [Identity Transform](quartzcore/identity-transform.md)
- [Scaling Filters](quartzcore/scaling-filters.md)
- [CATransform3D](quartzcore/catransform3d.md)
- [CALayer.DynamicRange](quartzcore/calayer/dynamicrange.md)

### Instance properties

- [cornerCurve](quartzcore/calayer/cornercurve.md)
- [wantsDynamicContentScaling](quartzcore/calayer/wantsdynamiccontentscaling.md)

### Type methods

- [cornerCurveExpansionFactor(_:)](quartzcore/calayer/cornercurveexpansionfactor(_:).md)

### Initializers

- [init(coder:)](quartzcore/calayer/init(coder:).md)

### Instance Properties

- [toneMapMode](quartzcore/calayer/tonemapmode-swift.property.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [CAEAGLLayer](quartzcore/caeagllayer.md)
- [CAEmitterLayer](quartzcore/caemitterlayer.md)
- [CAGradientLayer](quartzcore/cagradientlayer.md)
- [CAMetalLayer](quartzcore/cametallayer.md)
- [CAOpenGLLayer](quartzcore/caopengllayer.md)
- [CAReplicatorLayer](quartzcore/careplicatorlayer.md)
- [CAScrollLayer](quartzcore/cascrolllayer.md)
- [CAShapeLayer](quartzcore/cashapelayer.md)
- [CATextLayer](quartzcore/catextlayer.md)
- [CATiledLayer](quartzcore/catiledlayer.md)
- [CATransformLayer](quartzcore/catransformlayer.md)

### Conforms To

- [CAMediaTiming](quartzcore/camediatiming.md)
- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Layer Basics

- [CALayerDelegate](quartzcore/calayerdelegate.md)
- [CAConstraint](quartzcore/caconstraint.md)
- [CALayoutManager](quartzcore/calayoutmanager.md)
- [CAConstraintLayoutManager](quartzcore/caconstraintlayoutmanager.md)
- [CAAction](quartzcore/caaction.md)
