A specialized view that creates, configures, and displays Metal objects.
- iOS 9.0+
- macOS 10.11+
- tvOS 9.0+
MTKView class simplifies the effort required to create a Metal drawing application by providing a default implementation of a Metal-aware view. A
MTKView object provides a convenient way to manage a
MTLRender object and its associated render target attachments on your application’s behalf. You simply draw into the view when its contents need to be updated.
The view requires a
MTLDevice object so that it can create and manage Metal objects internally. Your app must set the device and, optionally, modify the view’s drawable properties before drawing. The
MTKView class supports three drawing modes:
For all of these drawing modes, when a redraw is requested, either
draw from a subclassed instance of the view is called, or
draw from the view’s delegate is called. You should either subclass
MTKView or provide a
delegate, but not both.
For each iteration of the draw loop, a new
MTLRender object is made available when queried from
current. This object is created based on the configured render target properties and the
current object. The default store and load actions are used, and it is expected that the render pass descriptor be used when creating your onscreen
MTLRender. Presentation is not handled by
MTKView, it is your responsibility to call the
present method on the view’s current drawable.