Reputation: 242
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?
Upvotes: 0
Views: 2939
Reputation: 5854
You can try a parameter to .tabViewStyle:
TabView(selection: $selectedPage) {
Text("1").tag(0)
Text("2").tag(1)
}
.tabViewStyle(.page(indexDisplayMode: .never))
This way you don't change the appearance of all UIPageControl's in the app.
Upvotes: 1
Reputation: 370
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
}
}
Upvotes: 3