It's obviously not the same, but a quick trick could be to use a VStack to render the views. Doing so you can easily space them.
Additionally, you can create a PreviewContainer based on VStack which you can use to give a name to the preview similarly as previewDisplayName does.
struct PreviewContainer<Content: View>: View {
@ViewBuilder let content: () -> Content
var body: some View {
VStack(spacing: 16) {
content()
}
.background(Color.white)
.previewLayout(.sizeThatFits)
.padding()
.background(Color.gray)
.cornerRadius(16)
.background(Color.clear)
}
}
struct PreviewCase<Content: View>: View {
let previewName: String
@ViewBuilder let content: () -> Content
var body: some View {
VStack(spacing: 16) {
Text(previewName)
content()
}
}
}
struct MyView_Previews: PreviewProvider {
static var previews: some View {
PreviewContainer {
PreviewCase(previewName: "Case 1") {
Capsule()
.frame(height: 56)
}
PreviewCase(previewName: "Case 2") {
Capsule()
.frame(height: 80)
}
}
}
}
And you will obtain something like this
You can iterate this as much as you want to make your perfect Preview rendering experience.
Hope this helps 😉