New in SwiftUI 4: NavigationStack & Layout Protocol.

AnthonyDesignCode
3 min readJul 5, 2022
SwiftUI 4: NavigationStack & Layout Protocol.

Hello everyone, welcome to a new SwiftUI tutorial. I hope you are all doing well? Today I am going to show you how to use NavigationStack & Layout protocol in SwiftUI 4 and Xcode 14.

What is NavigationStack in SwiftUI?

This is a view that displays a root view and enables you to present additional views over the root view. When we use a navigation stack to present a stack of views over a root view. we can add views to the top of the stack by clicking or tapping a NavigationLink, and remove views using built-in, platform-appropriate controls, like a back button or a swipe gesture. The stack always displays the most recently added view that hasn’t been removed, and doesn’t allow the root view to be removed.

What is Layout Protocol in SwiftUI?

This is a type that defines the geometry of a collection of views. You traditionally arrange views in your app’s user interface using built-in layout containers like HStack and Grid. If you need more complex layout behaviour, you can define a custom layout container by creating a type that conforms to the Layout protocol.

Let’s get started with opening up Xcode 14. We are going to code this all in the ContentView. We are going to start by adding in the simple data to…

--

--

AnthonyDesignCode

Hey 👋 I’m Anthony! I hope you are well?! Thank you for looking at my blog. Here you will learn how to make apps in SwiftUI for iOS 16! Thanks for reading.