0

I'am using tabView to display some onboarding screens in my app. I was using

  .onAppear() {
                UIPageControl.appearance().currentPageIndicatorTintColor = .black
                UIPageControl.appearance().pageIndicatorTintColor = .gray
            }

to modify the background of the indicators and color. But now page indicator not showing in iOS 14.5 devices.

Referred this Link and other multiple links , but it says to add constraints. How to do that in swiftUI?

Ae Ri
  • 185
  • 1
  • 12

1 Answers1

3

Add an init() to the View where you define the UIKit appearance.

struct YourView: View {
    init() {
        UIPageControl.appearance().currentPageIndicatorTintColor = .black
        UIPageControl.appearance().pageIndicatorTintColor = .gray
    }

    var body: some View {
        // Text("YourView") with TabView
    }
}
Björn
  • 338
  • 1
  • 13
  • 1
    Is it possible to change the design of pageIndicator? – Aminul Haque Aome Nov 09 '22 at 14:06
  • @AminulHaqueAome What exactly do you mean with the design? Do you want to change the shape of the indicators, the size, spacing etc.? For now, you can only change the color. If you want to change any other property, you should create your own indicator. This can be done by hiding the default indicators and then tagging the different views in your tabview with a variable which you can use to determine which indicator should be active and to animate between these. – Björn Nov 12 '22 at 01:23
  • I managed to design my own indicator. and thanks a lot for your response bro – Aminul Haque Aome Nov 12 '22 at 02:38