How can I change the color of pagination dots of UIPageControl?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
UIPageControl is a common pagination indicator used in onboarding and swipeable content flows. Changing dot colors is straightforward, but behavior can vary depending on iOS version, appearance APIs, and whether UIKit or SwiftUI hosts the control. A robust implementation sets colors directly, handles current page updates, and optionally configures global appearance.
Basic Dot Color Customization
The two key properties are:
pageIndicatorTintColorfor inactive dots.currentPageIndicatorTintColorfor active dot.
Set both properties to avoid default mixed styling.
Full Example in a View Controller
Link updatePage to your scroll-view paging logic.
UIAppearance for App-Wide Styling
If many screens use UIPageControl, set a shared appearance.
Use this carefully, because it affects every page control in the app unless scoped through containment APIs.
Dynamic Color and Dark Mode
Use dynamic system colors or custom trait-aware colors.
Dynamic colors keep contrast readable in both light and dark appearances.
iOS 14 Plus Indicator Images
Recent iOS versions allow custom indicator images for more control than plain tint colors.
You can also set per-page indicator image if design requires special markers.
Runtime Theme Switching
If your app supports in-app theme changes, update page-control colors when theme state changes instead of setting them once in viewDidLoad.
Call this during theme notifications so pagination style stays synchronized across screens.
SwiftUI Interop
In SwiftUI, PageTabViewStyle uses page indicators that can be customized with appearance proxies.
Be aware that appearance changes are global across SwiftUI views sharing the same process.
Storyboard and Interface Builder Notes
If your page control comes from storyboard, you can still set colors in viewDidLoad after outlets are connected. Interface Builder may preview one palette while runtime applies another, so always verify final colors on a real device in light and dark modes.
Accessibility and Contrast
Color customization should maintain clear contrast and selection visibility. If active and inactive dots are too similar, pagination state becomes hard to read.
Test with:
- Light and dark modes.
- Increased contrast accessibility setting.
- Different background colors behind page control.
Visual QA matters as much as API correctness. Also verify appearance in right-to-left layouts and larger text settings where surrounding layout can shift page control placement and perceived readability. Consistency across themes improves onboarding polish significantly. Users notice this.
Common Pitfalls
- Setting only one tint property. Fix by setting both current and inactive dot colors.
- Applying global appearance unintentionally. Fix by scoping styling to local controls when needed.
- Choosing low-contrast color pairs. Fix by testing readability in light and dark themes.
- Forgetting to update
currentPageduring scroll. Fix by syncing page control in scroll callbacks. - Assuming SwiftUI styles are local only. Fix by remembering appearance proxy affects global UIPageControl instances.
Summary
- Customize dots with
pageIndicatorTintColorandcurrentPageIndicatorTintColor. - Use local styling for screen-specific UI and appearance proxy for global themes.
- Consider dynamic colors for dark mode support.
- Sync
currentPagewith page transitions. - Validate accessibility contrast before shipping.
Related reading
- How can I change the image displayed in a UIImageView programmatically?
- How can I change the name of an iOS app in Xcode?
- How can I change the name of an iOS app in Xcode?
- How can I change the UISearchBar search text color?
- How can I change UIButton title color?
- How can I check for an active Internet connection on iOS or macOS?
- How can I check for an active Internet connection on iOS or macOS?
- How can I check if a view is visible or not in Android?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.