Skip to content

Instantly share code, notes, and snippets.

@tomasen
Last active January 16, 2022 04:20
Show Gist options
  • Save tomasen/363a949c928787de0c3d1badbf113f18 to your computer and use it in GitHub Desktop.
Save tomasen/363a949c928787de0c3d1badbf113f18 to your computer and use it in GitHub Desktop.
Look-alike TabView inside NavigationView in iOS
// Created by SHEN SHENG on 1/16/22.
// This code is a part of the Wordbook iOS app.
// Wordbook is an App to help memorize and learn new English words.
// website: https://www.wordbook.cool
@State private var tabSelection = 1
var body: some View {
NavigationView {
VStack{
switch tabSelection {
default:
TabTwoView()
case 2:
TabOneView()
}
Spacer()
Divider()
HStack{
Spacer()
VStack{
Image(systemName: "play.rectangle")
Text("Today")
.padding(.top, 1)
}
.foregroundColor(tabSelection == 1 ? Color("fontLink") : Color("fontBody"))
.onTapGesture {
tabSelection = 1
}
Spacer()
VStack{
Image(systemName: "book")
Text("Lexicon")
.padding(.top, 1)
}
.foregroundColor(tabSelection == 2 ? Color("fontLink") : Color("fontBody"))
.onTapGesture {
tabSelection = 2
}
Spacer()
}
.padding(.top, 5)
}
.navigationBarTitle("Wordbook", displayMode:NavigationBarItem.TitleDisplayMode.inline)
.navigationBarItems(leading: leadingBarItem(),
trailing: trailingBarItem())
EmptyView()
}
.navigationViewStyle(.stack)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment