Search code examples
swiftswiftui

change TabView indicator color SwiftUI


enter image description here

Is there a way to change the tabView Indicator color in swiftUI ?

This is my code

struct OnBoarding: View {
    var body: some View {
        TabView {
            ForEach(0 ..< 3) { item in
                VStack {
                    Image("discover")
                        .resizable()
                        .scaledToFit()
                }
            }
        }
        .tabViewStyle(PageIndexViewStyle(backgroundDisplayMode: Color ?))   
    }
}

struct OnBoarding_Previews: PreviewProvider {
    static var previews: some View {
        OnBoarding()
    }
}

I tried tabViewStyle(PageIndexViewStyle(backgroundDisplayMode: Color ?)), but can't get around with it.


Solution

  • you need to use UIkit

     init() {
        UIPageControl.appearance().currentPageIndicatorTintColor = .red
        UIPageControl.appearance().pageIndicatorTintColor = UIColor.black.withAlphaComponent(0.2)
        }