Skip to content

Instantly share code, notes, and snippets.

@rushairer
Created April 24, 2021 04:42
Show Gist options
  • Select an option

  • Save rushairer/5d4d9013274883f209fb28a8cad49863 to your computer and use it in GitHub Desktop.

Select an option

Save rushairer/5d4d9013274883f209fb28a8cad49863 to your computer and use it in GitHub Desktop.
NavigationView with TabView Like the popular Chat apps.
//
// ContentView.swift
// Test
//
// Created by Abenx on 2021/4/24.
//
import SwiftUI
import CoreData
struct ContentView: View {
@Environment(\.managedObjectContext) private var viewContext
@State var tabTag = 1
var body: some View {
NavigationView {
TabView(selection: $tabTag) {
List {
NavigationLink(
destination: Text("Tab Content 1"),
label: {
Text("Tab Content 1")
})
}
.navigationTitle("Tab1`")
.tabItem { Text("Tab Label 1") }.tag(1)
List {
NavigationLink(
destination: Text("Tab Content 2"),
label: {
Text("Tab Content 2")
})
}
.navigationTitle("Tab2")
.tabItem { Text("Tab Label 2") }.tag(2)
}
.navigationTitle("Tab\(tabTag)")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment