A layer that manages a pool of Metal drawables.


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 a Metal Layer

var device: MTLDevice?

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

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.

Rendering to a Metal Layer

func nextDrawable()

Returns a Metal drawable.

var presentsWithTransaction: Bool

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

Extended Dynamic Range

var wantsExtendedDynamicRangeContent: Bool

Enables extended dynamic range values on the screen.


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 CAOpenGLLayer

CAOpenGLLayer 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 (CGL) context.