Contents

PreviewLayout

A size constraint for a preview.

Declaration

enum PreviewLayout

Overview

Customize the layout of a preview that you define using the PreviewProvider protocol by providing one of the preview layout values to the previewLayout(_:) view modifier. For example, you can tell the preview to take up only the amount of space that the view requires with PreviewLayout.sizeThatFits:

struct CircleImage_Previews: PreviewProvider {
    static var previews: some View {
        CircleImage()
            .previewLayout(.sizeThatFits)
    }
}

Topics

Getting a layout

See Also

Preview definition