Custom Tab Bar - Linking Tabbuttons to Views - My First App!

Hi Everyone,

I’m currently on my journey to developing my first app. I have used Chris’ video on the custom tab bar, https://www.youtube.com/watch?v=R_KZwX-yP4o.

The coding has worked great with my original code; however, he doesn’t show how to like the tabbuttons to open their respective Views.
Could I please have some assistance with this?

Cheers, Nic

@nlaspina

Hi Nic,

Welcome to the community.

Bear in mind that the video you were watching was a lesson straight out of the Chat App build on CWC+ so the code required to enable you track which tab has been selected is provided in a later lesson in that course.

In the description below the video Chris Ching makes that point with the notes saying:

Watch me build a custom tab bar in SwiftUI based on a custom UI that was designed in Figma. This lesson is just one of the 30+ lessons that’s inside our “How to Build a Chat App” course on CWC+, so if you want to learn more, make sure to explore the links below!

What happens is that back in the Root View there is a switch statement on selectedTab where if the case is .chats then open the ChatsListView and if the case is .contacts then open the ContactsListView. Obviously you configure the enum to be whatever you want it to be for your application and the views that align with the Tabs are named whatever you want them to be.

Hi Chris,

Thank you so much. Just that little explanation you made down below helped me fix my code and now works better than ever. Thanks a lot and enjoy your festive holidays!

Cheers, Nic

1 Like