[SwiftUI] TwitterClone: TabBar

Junyoung ParkΒ·2022λ…„ 11μ›” 15일
0

SwiftUI

λͺ©λ‘ 보기
98/136
post-thumbnail
post-custom-banner

πŸ”΄ Let's Build Twitter with SwiftUI (iOS 15, Xcode 13, Firebase, SwiftUI 3.0)

TwitterClone: TabBar

κ΅¬ν˜„ λͺ©ν‘œ

  • νƒ­λ°” κ΅¬ν˜„

κ΅¬ν˜„ νƒœμŠ€ν¬

  • 인덱슀 연결을 ν†΅ν•œ λ·° 바인딩

μ†ŒμŠ€ μ½”λ“œ

import SwiftUI

struct MainTabView: View {
    @State private var selectedIndex: Int = 0
    var body: some View {
        TabView(selection: $selectedIndex) {
            FeedView()
                .onTapGesture {
                    selectedIndex = 0
                }
                .tabItem {
                    Image(systemName: "house")
                }
                .tag(0)
            ExploreView()
                .onTapGesture {
                    selectedIndex = 1
                }
                .tabItem {
                    Image(systemName: "magnifyingglass")
                }
                .tag(1)
            NotificationsView()
                .onTapGesture {
                    selectedIndex = 2
                }
                .tabItem {
                    Image(systemName: "bell")
                }
                .tag(2)
            MessagesView()
                .onTapGesture {
                    selectedIndex = 3
                }
                .tabItem {
                    Image(systemName: "envelope")
                }
                .tag(3)
        }
    }
}

κ΅¬ν˜„ ν™”λ©΄

profile
JUST DO IT
post-custom-banner

0개의 λŒ“κΈ€