swiftui-navigation-transitions
swiftui-navigation-transitions copied to clipboard
Change fade transient view background color
thank you for creating this library @davdroman!
I have a global background color in my app (implemented using the ZStack approach). How do I change the fade transition to have the same color?
https://github.com/davdroman/swiftui-navigation-transitions/assets/21252681/0f49c294-4243-4d7f-bbac-22537352081b
notice how the background changes to white (black if dark mode) during the fade transition.
I am wondering the same thing. did you find a solution?
Just chiming in about this case:
The fade transition in itself works great! However, all the fading seems to not keep the previous view which leaves an opportunity to show the internal hosting controller background.
There are workarounds to this; you can tint the color of the internal hosting by just making an UIViewRepresentable that returns an UIView that doesn't do anything other than access the superview internally and setting the background to the color you want:
struct TransparentBackground: UIViewRepresentable {
func makeUIView(context: Context) -> UIView {
let view = UIView()
DispatchQueue.main.async {
view.superview?.superview?.backgroundColor = .clear
}
return view
}
func updateUIView(_ uiView: UIView, context: Context) {}
}
Then using it with .background(TransparentBackground())
The other thing was to bring the UIKit fade animation so it correctly fades both the views with PrimitiveNavigationTransition, however, it seems there are some internal issues with this as I get a wonky navigation bar behavior when returning to the root view and pushing again (the navigation bar visibility is hidden but you can still interact with it), as well I also found that on func transition(with animator: Animator, for operation: TransitionOperation, in context: Context), the destination view for some reason has it's user interaction disabled.
I was wondering @davdroman if there is a way to make a fade that keeps the current view in place and just fades in the new view to present? 🤔