Posts

Post not yet marked as solved
5 Replies
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 😉
Post marked as solved
6 Replies
I thought the same ... i'm interested in the thread.Maybe SwiftUI is still very very, very, young and does not offer this capability out of the box and in the first iteration we will require to wrap an UICollectionView from UIKit, same as MapView tutorial. The same will apply to other components like PageControl if I'm not wrong, i don't see it.Probably very soon will start to come out 3rd parties views as libraries. It would be super easy to use them as new, more evoluted, building blocks and than in future Apple will "absorbe" them in newer version of SwiftUI proposing their enhanced variant.