'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:

enter image description here

what I want to achieve is:

  1. hiding the dots.

  2. adding Text views (or tags) on top of PageView to show the rows that belongs to a specific category, exactly like what's done in YouTube app:

enter image description here

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