ContentView.swift
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | // // ContentView.swift // Swiftuitest // // Created by Cairocoders // import SwiftUI struct ContentView: View { @State private var selection = 0 var body: some View { ZStack(alignment: .topTrailing) { NavigationView { TabView(selection: $selection) { Home() .tabItem { Image(systemName: "house.fill" ) Text( "Home" ) } .tag(0) Text( "Bookmark Tab" ) .font(. system (size: 30, weight: .bold, design: .rounded)) .tabItem { Image(systemName: "bookmark.circle.fill" ) Text( "Bookmark" ) } .tag(1) Text( "Video Tab" ) .font(. system (size: 30, weight: .bold, design: .rounded)) .tabItem { Image(systemName: "video.circle.fill" ) Text( "Video" ) } .tag(2) Text( "Profile Tab" ) .font(. system (size: 30, weight: .bold, design: .rounded)) .tabItem { Image(systemName: "person.crop.circle" ) Text( "Profile" ) } .tag(3) } //end tabview .onAppear() { UITabBar.appearance().barTintColor = .white } .accentColor(.orange) //Tab Bar Color .navigationTitle( "TabView Demo" ) .navigationBarItems(leading: HStack { Button(action: { selection = (selection + 1) % 4 }) { Text( "Next" ) .font(. system (.headline, design: .rounded)) .padding() .foregroundColor(.white) .background(Color.green) .cornerRadius(10.0) .padding() } } ) } // end NavigationView } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // // Home.swift // Swiftuitest // // Created by Cairocoders // import SwiftUI struct Home: View { var body: some View { List(1...50, id: \.self) { index in NavigationLink( destination: Text( "Item #\(index) Details" ), label: { Text( "Item #\(index)" ) .font(. system (size: 20, weight: .bold, design: .rounded)) }) } } } struct Home_Previews: PreviewProvider { static var previews: some View { Home() } } |