init(_:traits:body:)
Creates a preview of a SwiftUI view.
Declaration
@MainActor init(_ name: String? = nil, traits: PreviewTrait<Preview.ViewTraits>..., body: @escaping @MainActor () -> any View)Parameters
- name:
An optional display name for the preview.
- traits:
An optional list of Previewtrait instances that customize the appearance of the preview.
- body:
A view builder that produces a SwiftUI view to preview.
Discussion
Preview macros expand into a declaration that calls this initializer. Don’t use this initializer directly. Instead use one of the macros, like Preview(_:body:).