Preview
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
Group {
ContentView()
.preferredColorScheme(.dark) // dark mode
.previewDevice("iPhone 13 Pro Max") // preview device
.previewDisplayName(deviceName) // display name
ContentView()
}
}
}
// available methods
.previewLayout(.sizeThatFits) // preview layouts
.previewLayout(.fixed(width: 600, height: 600))
.previewInterfaceOrientation(.landscapeRight) // preview orientation
.environment(\.sizeCategory, .extraExtraExtraLarge) // accessibility
Design+Code โฉ Layout Code & Preview
SwiftUI Tutorials โฉ Sec. 8: Generate Previews Dynamically - Step 2
PreviewDevice (struct)
Last updated