A layer that manages a pool of Metal drawables.


class CAMetalLayer : CALayer


To use Metal for rendering in your app, use this class as the backing layer for a view by returning it from your view’s layerClass class method. To render the layer’s content, use the nextDrawable() method to retrieve a texture, then use it as a render target in a Metal rendering pipeline. After rendering each frame, you present the new content for display with the present(_:) or present(_:atTime:) method of the command buffer you used for rendering.


Configuring the Metal Layer

var pixelFormat: MTLPixelFormat

The pixel format of textures for rendering layer content.

var framebufferOnly: Bool

A Boolean value that determines whether the layer’s textures are restricted for use as framebuffer attachments.

var drawableSize: CGSize

The size, in pixels, of textures for rendering layer content.

var colorspace: CGColorSpace?

The color space of the rendered content.

var presentsWithTransaction: Bool

A Boolean value that determines whether the layer presents its content using a Core Animation transaction.

var wantsExtendedDynamicRangeContent: Bool

Enables extended dynamic range values on the screen.

var edrMetadata: CAEDRMetadata?

Metadata describing the tone mapping to apply to the extended dynamic range (EDR) values in the layer.

var displaySyncEnabled: Bool

A Boolean value that determines whether the Metal layer and it's drawables are synchronized with the display's refresh rate.

var allowsNextDrawableTimeout: Bool

A Boolean value that determines whether Metal drawables are allowed to time out or wait indefinitely.

var maximumDrawableCount: Int

An integer value that controls the number of Metal drawables in the resource pool managed by Core Animation.

Obtaining a Metal Drawable

Obtaining the Metal Device

var device: MTLDevice?

The Metal device responsible for the layer’s drawable resources.


Inherits From

Conforms To

See Also

Metal and OpenGL

protocol CAMetalDrawable

A displayable resource that can be rendered or written to by Metal.

class CAEAGLLayer

A layer that supports drawing OpenGL content in iOS and tvOS applications.

class CAEDRMetadata

Metadata describing how extended dynamic range (EDR) values should be tone mapped.

class CAOpenGLLayer

A layer that provides a layer suitable for rendering OpenGL content.

class CARenderer

A layer that allows an application to render a layer tree into a Core OpenGL context.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software