Search code examples
iosswiftuipagecontrol

How fix position of UIPageControl ? Fix it always on top when page is changing with PageViewController?


I'm made on-boarding screen with PageViewController for sliding and ReviewViewController as ViewController for content.

Every time when i slide a page I create new ReviewViewController with right content inside.

On ReviewViewController I've got Image, Label and PageControl

Everything works good But - when I slide a to the next page - PageControl slide out like image or label, but I want to fix it and change only color.

One more time - when i slide every elements slide out, I want to fix PageControl always on the same position on the screen

Please give advise.

Image of my StoryBoard


Solution

  • You can achieve this using a container view. Rather than making the UIPageViewController the rootViewController of your UINavigationController, add an intermediate UIViewController that has a container view subview, and add the UIPageControl as a sibling.

    You should remove the UIPageControl from your sub view controllers.

    You'll need to add some way of propagating page updates back to the UIPageControl - a delegate protocol or closures will work nicely for this.

    enter image description here