Contents

PreviewCamera

A camera that defines a viewpoint in a preview.

Declaration

struct PreviewCamera

Overview

Use one or more preview cameras with one of the preview macros that takes a cameras input — like Preview(_:traits:body:cameras:) — to create custom viewpoints for the preview. The canvas offers custom cameras in its camera picker along with a set of standard cameras. The preview uses the first custom camera that you specify as the default viewpoint when the preview appears.

For example, you can create custom cameras from the top, leading, and front viewpoints:

#Preview {
    CircleImage()
} cameras: {
    PreviewCamera(from: .top, name: "Top")
    PreviewCamera(from: .leading, name: "Leading")
    PreviewCamera(from: .front, name: "Front")
}

Topics

Creating a preview camera

See Also

Preview camera management