Search code examples
uipageviewcontrolleruipagecontrol

Dynamically hide or position video above dots in UIPageViewcontroller (e.g., UIPageControl)?


Is it possible to position a video above a UIPageControl (i.e., the dots of a UIPageViewController)?

One of the view controllers managed by a UIPageViewController shows a video when the user taps on it.

After the tap, is it possible to position the video above the dots? Setting the zPosition of the video view higher than the UIPageControl failed, and this answer explains zPosition has no effect unless the UIPageControl and the video are siblings.

From other StackOverflow answers, it doesn't seem possible to dynamically hide the dots, which would also work.


Solution

  • Swift 4 answer to dynamically hide dots:

    Works:

    for subview in self.view.subviews {
        if subview is UIPageControl {
            subview.isHidden = true
        }
    }
    

    Fails:

    let pageControl = UIPageControl.appearance(whenContainedInInstancesOf: [type(of: self)])
    pageControl.isHidden = true