Learn Courses My Dashboard

Switch to another "View (SwiftUiView) with a Button

Hi there,

i just watched the wonderful video “How to build a Custom Tab Bar” and wanted to know how do I switch to a different View (in this case to Chats) with the “Button command”

Here is my code:

import SwiftUI

struct CustomTabBar: View {
    var body: some View {
       
        HStack {
            
            Button {
                //Switch to Chats
            } label: {
                
                VStack (alignment: .center, spacing: 4){
                    Image("grafik")
                        .resizable()
                        .scaledToFit()
                        .frame(width: 24, height: 24)
                    Text("Chats")
                       
                }
            }
           
            }
        .frame(height:82)
            
            
        }
    }


struct CustomTabBar_Previews: PreviewProvider {
    static var previews: some View {
        CustomTabBar()
    }
}

Thank you

Do you have CWC+?

Hi ekraus,
unfortunately not. But when you say I need it i will subscribe.

Hi, i just bought the CWC+, can someone give me the link maybe to a solution in the CWC+ library ?
Thank you

https://learn.codewithchris.com/courses/take/chat/texts/29342063-resources

If you subscribed, you’ll be able to see the solution here.

1 Like

Fundamentals course is also a good place to start.

1 Like