Search code examples
iosswiftswiftuiios13

Is there a way to create BottomBar using SwiftUI?


I want to create a bottom bar which should be common for all my page. Here I am posting the image:

Here

I know how to do it using storyboard. But how can I do it in SwiftUI?


Solution

  • This kind of view is called tab bar in iOS and in SwiftUI it is called TabView. It is declared like this:

    var body: some View {
        TabView {
            Text("Favourites Screen")
                .tabItem {
                    Image(systemName: "heart.fill")
                    Text("Favourites")
            }
            Text("Friends Screen")
                .tabItem {
                    Image(systemName: "person.fill")
                    Text("Friends")
            }
            Text("Nearby Screen")
                .tabItem {
                    Image(systemName: "mappin.circle.fill")
                    Text("Nearby")
            }
        }
    }
    

    Tab bar