Search code examples
iosswiftuipageviewcontroller

Adding dots to bottom of UIPageViewController screen


I have implemented the data source methods of UIPageViewController and still not getting dots at bottom of my iOS app. Anybody have any solution to make dots appear on my app?


Solution

  • When you use UIPageViewController the dots should be visible by default. I guess you have a white background and the dots are also white, so you just don't see them.

    Try to change dots color:

    Swift 4/5:

    var appearance = UIPageControl.appearance(whenContainedInInstancesOf: [UIPageViewController.self])
    appearance.pageIndicatorTintColor = UIColor.red
    appearance.currentPageIndicatorTintColor = UIColor.red
    

    Swift 3:

    var appearance = UIPageControl.appearanceWhenContainedIn(UIPageViewController.self, nil)
    appearance.pageIndicatorTintColor = UIColor.red
    appearance.currentPageIndicatorTintColor = UIColor.red
    

    If it doesn't help, make sure that you are using UIPageViewControllerTransitionStyleScroll transition style.

    Also, make sure to implement this methods from the UIPageViewControllerDataSource: presentationCount(for:) and presentationIndex(for:).