'SwiftUI: customizing TabView's PageTabViewStyle to show tags instead of dots
I'm using the following code to show a list of pages horizontally using TabView:
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView {
LazyHStack {
PageView()
}
}
}
}
struct PageView: View {
var body: some View {
TabView {
ForEach(0..<30) { i in
ZStack {
Color.black
Text("Row: \(i)").foregroundColor(.white)
}
}
.padding(.all, 10)
}
.frame(width: UIScreen.main.bounds.width, height: 200)
.tabViewStyle(PageTabViewStyle())
}
}
however, this shows dots at the bottom:
what I want to achieve is:
hiding the dots.
adding
Textviews (or tags) on top ofPageViewto show the rows that belongs to a specific category, exactly like what's done in YouTube app:
is this possible with PageTabViewStyle ?
Solution 1:[1]
Just use style PageIndexViewStyle.never and change tabs programmatically on tags selection as in https://stackoverflow.com/a/62833840/12299030.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Asperi |


