SwipeableTabView is a tab view built using SwiftUI that can be swiped horizontally.
Please install SwipeableTabView via Swift Package Manager.
SwipeableTabView can be used in much the same way as the SwiftUI TabView. Please set an array of SwipeableTabTitle structure instances.
import SwiftUI
import SwipeableTabView
struct ContentView: View {
@State var selection: Int = 0
let titles: [SwipeableTabTitle<Int>] = [
.init(tag: 0, text: "Tab\(0)"),
.init(tag: 1, text: "Tab\(1)"),
.init(tag: 2, text: "Tab\(2)"),
]
var body: some View {
SwipeableTabView(selection: $selection,
titles: titles) {
ForEach(titles) { title in
Text(title.text)
// Set same value as SwipeableTabTitle's tag.
.tag(title.tag)
}
}
}
}