previewLayout(_:)
Overrides the size of the container for the preview.
Declaration
nonisolated func previewLayout(_ value: PreviewLayout) -> some View
Parameters
- value:
A layout to use for preview.
Return Value
A preview that uses the given layout.
Discussion
By default, previews use the PreviewLayout/device layout, which places the view inside a visual representation of the chosen device. You can instead tell a preview to use a different layout by choosing one of the PreviewLayout values, like PreviewLayout/sizeThatFits:
struct CircleImage_Previews: PreviewProvider {
static var previews: some View {
CircleImage()
.previewLayout(.sizeThatFits)
}
}