Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customise Position of UIPageControl

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

like image 455
Mohammad Sadiq Shaikh Avatar asked Nov 30 '25 03:11

Mohammad Sadiq Shaikh


2 Answers

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)
          }
      }
  }
}
like image 180
Hussein Dimessi Avatar answered Dec 02 '25 21:12

Hussein Dimessi


The project uses a UIPageViewController to handle the display and movement through the content. You can supply data to that object so it displays a UIPageControl as you say. BUT you have no control over the display of that item, other than maybe some colour styling. If you want to position it, you'll need to implement you're own instance of UIPageControl and handle it's content, position and changes manually.

like image 27
Cocoadelica Avatar answered Dec 02 '25 19:12

Cocoadelica



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!