美文网首页
SwiftUI: 用非系统图来处理tabView

SwiftUI: 用非系统图来处理tabView

作者: 大布溜 | 来源:发表于2020-07-03 11:09 被阅读0次
    import SwiftUI
    
    struct ContentView: View {
        @State private var selection = 3
        
        var body: some View {
            TabView (selection:$selection){
                Text("Tab Content 1").tabItem {
                    Text("图表")
                    Image(selection == 1 ? "chart_icon" : "chart_icon_gray")
                    }.tag(1)
                            
                    Text("Tab Content 2").tabItem { Text("账户")
                        Image(selection == 2 ? "account_icon" : "account_icon_gray")
                    }.tag(2)
                    TurnOverView().tabItem {
                        Text("流水")
                        Image(selection == 3 ? "turnover_icon" : "turnover_icon_gray")
                    }.tag(3)
                    Text("Tab Content 4").tabItem { Text("预算")
                        Image(selection == 4 ? "budget_icon" : "budget_icon_gray")
                    }.tag(4)
                    Text("Tab Content 5").tabItem { Text("我的")
                        Image(selection == 5 ? "mine_icon" : "mine_icon_gray")
                    }.tag(5)
            }.accentColor(Color.black)
        }
    }
    
    struct ContentView_Previews: PreviewProvider {
        static var previews: some View {
            ContentView()
        }
    }
    

    相关文章

      网友评论

          本文标题:SwiftUI: 用非系统图来处理tabView

          本文链接:https://www.haomeiwen.com/subject/syzjqktx.html