I am implementing a TabView in SwiftUI, I want to detect when the colorScheme changes because I implemented a custom page indicator with colors which depends of colorScheme. tabView contains a method named onAppear() where I call to setUpApariencie() but if I change the colorScheme when the app is running, the changes on de page indicator dont work. I show you the code:
}
.tabViewStyle(.page(indexDisplayMode: .always))
.indexViewStyle(.page(backgroundDisplayMode: .always))
.frame( height: heigth * 0.4)
.onAppear(){
setupAppearance()
}
}
}
}
}
func setupAppearance() {
UIPageControl.appearance().currentPageIndicatorTintColor = colorScheme == .light ? .black : .white
UIPageControl.appearance().pageIndicatorTintColor = UIColor.black.withAlphaComponent(0.2)
}
one more thing, I dont know why withAlphaComponent doesnt do anything. thanks.