I want to rotate my view so that it changes its frame and covers the entire screen on rotation. I've tried all the types of rotations along with different anchors. This was working perfectly fine in iOS 13 but inside iOS 14 there is a strange gap between the view and the margin.
struct ContentView: View {
@State private var isFullScreen = false
var body: some View {
NavigationView {
GeometryReader { geometry in
ZStack(alignment: .center) {
VStack(spacing: 0) {
HStack(alignment: .top)
{
Spacer(minLength: 0)
ZStack(alignment: Alignment(horizontal: .trailing, vertical: .center)) {
RoundedRectangle(cornerRadius: 0)
.foregroundColor(Color.yellow)
VStack {
Button(action: {
self.isFullScreen.toggle()
}, label: {
Text("FS")
})
}
}
.frame(width: self.isFullScreen ? geometry.size.height : geometry.size.width, height: self.isFullScreen ? geometry.size.width : geometry.size.height / 3)
.rotation3DEffect(
Angle(degrees: isFullScreen ? -90 : 0),
axis: (x: 0.0, y: 0, z: 1.0),
anchor: .bottom,
anchorZ: 0.0,
perspective: 1.0
)
}
}
}.background(Color.red)
.navigationBarHidden(self.isFullScreen)
.navigationBarTitle(self.isFullScreen ? "" : "Demo", displayMode: .inline)
}
}.navigationViewStyle(StackNavigationViewStyle())
}
}