Instance Property


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


var presentsWithTransaction: Bool { get set }


By default this value is false: CAMetalLayer displays the output of a rendering pass to the display as quickly as possible and asynchronously to any Core Animation transactions. However, if your game or app combines Metal and Core Animation content, it's not guaranteed that your Metal content will arrive in the same frame as your Core Animation content. This could be an issue if, for example, your app draws UIKit content (such as labels with a target position and time) over the top of your CAMetalLayer and the two domains need to be synchronized.

Setting this value to true changes this default behavior so that your CAMetalLayer displays its drawable content synchronously, using whichever Core Animation transaction is current at the time the drawable’s present() method is called.

However, if you allow Metal to choose when to call the present method (by using the present(_:) method of a command buffer), the transaction during which you scheduled presentation might end before the drawable is ready to be presented. To avoid this situation, commit the command buffer and call its waitUntilScheduled() method to synchronously wait until the drawable is ready, then call the drawable’s present() method directly.

See Also

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 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.

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