Navigating between multiple views with TabView
TabView is another navigation container that switches between multiple child views, using a bar with buttons commonly placed at the bottom of the screen. When the user taps on one of the buttons in the tab bar, the view associated with that tab replaces the previously selected view. A typical example of using this navigation container is the Music app on iOS. Tab views are usually used as the root view of an app, and they are useful to show unrelated content in each tab. For related content, we would use a navigation stack or a navigation split view, as we saw in the previous recipes.
Getting ready
Create a new SwiftUI iOS app named UsingTabViews.
How to do it…
- We will create an app with a TabView with two child views. One will display the made-up best games of 2021, while the other will display various currencies used around the world. The steps are given here:
- Create a new SwiftUI view file named HomeView, and update HomeView...