When I dismiss a view presented with .navigationTransition(.zoom), the source view gets a weird background (black or white depending on the appearance) for a couple of seconds, and then it disappears.
Here’s a simple code example.
import SwiftUI
struct NavigationTransition: View {
@Namespace private var namespace
@State private var isSecondViewPresented = false
var body: some View {
NavigationStack {
ZStack {
DetailView(namespace: namespace)
.onTapGesture {
isSecondViewPresented = true
}
}
.fullScreenCover(isPresented: $isSecondViewPresented) {
SecondView()
.navigationTransition(.zoom(sourceID: "world", in: namespace))
}
}
}
}
struct DetailView: View {
var namespace: Namespace.ID
var body: some View {
ZStack {
Color.blue
Text("Hello World!")
.foregroundStyle(.white)
.matchedTransitionSource(id: "world", in: namespace)
}
.ignoresSafeArea()
}
}
struct SecondView: View {
var body: some View {
ZStack {
Color.green
Image(systemName: "globe")
.foregroundStyle(Color.red)
}
.ignoresSafeArea()
}
}
#Preview {
NavigationTransition()
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I noticed that trying to access safeAreaInsets from the active window causes an infinite run loop.
This issue appeared after updating to Beta 3.
Here’s an example of the code:
extension UIDevice {
var safeAreaInsets: UIEdgeInsets {
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first(where: { $0.isKeyWindow }) else {
return .zero
}
return window.safeAreaInsets
}
}
The return doesn’t happen because it ends up in some kind of recursion.