I recently switched from Storyboard to SwiftUI and I am having a hard time trying to preview my work. My target is an iPad Air 3rd Gen which only accepts landscape mode.
As mentionned here, it is not currently supported in XCode. Some people suggests that you can fix the size of the preview to simulate a rotation. However it does not render the same, the outlets looks too small compared to the original device.
Here is my example with an iPad Air 3rd gen which is 2224 x 1668 pixels
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().rotationEffect(Angle(degrees: 90)) // to simulate the rotation on device
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().previewLayout(.fixed(width: 2224, height: 1668)) // To simulate device size
}
}
As you can see the two previews does not match and the result on the simulator is conform to the first preview with rotationEffect, but it forces me to tilt my head each time I want to see my preview.
Is there another way to DIY a rotation in SwiftUI ?




