Customise Position of UIPageControl

Mohammad Sadiq Shaikh picture Mohammad Sadiq Shaikh · Jul 24, 2014 · Viewed 7.8k times · Source

I am using project from github as a reference.

project URL:

https://github.com/lephuocdai/iOSsample/tree/master/PageViewDemo

In this project i want to show the UIPageControl at top left position .

I tried setting the rect property of pageControl using CGRectMake() to some value ;But it shows always at bottom center

Answer

Hussein Dimessi picture Hussein Dimessi · Nov 1, 2016

here s a very neat and 100% effective way to get to change the position of the pageControl

extension UIPageViewController {
  override open func viewDidLayoutSubviews() {
      super.viewDidLayoutSubviews()

      for subV in self.view.subviews {
          if type(of: subV).description() == "UIPageControl" {
              let pos = CGPoint(x: newX, y: newY)
              subV.frame = CGRect(origin: pos, size: subV.frame.size)
          }
      }
  }
}