TabStack is a SwiftUI-based library for iOS app development that makes it easy to implement tab-based navigation. It makes it easy to configure multi-tabbed interfaces with just a few lines of code, without the need for complex tab management logic.
- Xcode, select from the menu File > Swift Packages > Add Package Dependency
- Specify the URL https://github.com/hyukggun/TabStack
//
// TabHStackExamplePage.swift
import SwiftUI
import TabStack
enum MovieSections: CaseIterable {
case nowPlaying
case popular
case upcoming
var title: String {
switch self {
case .nowPlaying:
"Now Playing Movies"
case .popular:
"Popular Movies"
case .upcoming:
"Upcoming Movies"
}
}
}
struct TabHStackExamplePage: View {
let sections = MovieSections.allCases
@State
var selectedTab: MovieSections? = .nowPlaying
var body: some View {
TabHStack(tabValues: sections, selectedTab: $selectedTab) { currentTab, isSelected in
HStack {
Text(currentTab.title)
if isSelected {
Image(systemName: "checkmark")
}
}
}
}
}
TabStack is distributed under the MIT license. For more information, see the LICENSE file.