DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Fixing SwiftUI navigation with UIKit
Raksha for Canopas Software

Posted on

Fixing SwiftUI navigation with UIKit

You must be aware that Apple hasn’t implemented SwiftUI from scratch, those SwiftUI views are just wrappers around UIKit views.Β 

While SwiftUI makes development easy and fun, Apple did a terrible job with some of the basics like navigation and tabs.

It doesn’t have all the capabilities that UIKit had and has a few major bugs as well like
You can not do multiple operations on NavigationView/Stack (Want to pop 1 view and push a new one at the same, not possible.)
It’s not possible to observe current views in NavigationStack (How can we take decisions based on stack apple?)
Terrible animations whenever multiple views are popped off the stack.
You can not control whether push/pop operations should be animated
TabView does not have native behavior of popping stack and scrolling to the top when tapped multiple times (Really apple?)

Those are only some of the things, you will discover much more as you use SwiftUI.

In today’s article, you will see how you can wrap UIKit navigation with SwiftUI. You will be amazed at how easy and simple it is.

For detailed implementation, visit canopas blog.

Top comments (0)

Join us at DEV
Yes, this is technically an β€œad”, but really we just want to ask if you want to join DEV. We have 900k+ developers reading, posting, and enjoying community, and would love to have you. Β  Create an account and continue your coding journey.