12

I am trying to change the height of UIPageControl how I can achieve that?

Ahmad Kayyali
  • 8,233
  • 13
  • 49
  • 83
  • Yes set the frame for it.. 'pageControl.frame = CGRectMake(x, y, width, height);' – nik May 18 '11 at 10:59

9 Answers9

9

Not using interface builder, but you can specify a new frame in code:

pageControl.frame = CGRectMake(x, y, width, height);
Mike Weller
  • 45,401
  • 15
  • 131
  • 151
3

This is how you do that

Change the width to something strange, 153

Now open the xib as source.

Find 153

Nearby you should see number 36. Change that to the height you want.

Tada...... :)

Septiadi Agus
  • 1,775
  • 3
  • 17
  • 26
  • Thank you! My page control was 291 px high and I could not change it in the storyboard. Changing it in the source code fixed it and also helped me fixing the constraint warnings I had when running the application. Brilliant idea searching for the strange numbers. – Erlend Dec 01 '20 at 18:45
3

Agree With Mike

You can change your UIPageControl height using its frame..

ex

 pgControl.frame = CGRectMake(X , Y , Width , Height that you want);
Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94
2

I had the same issue, but wanted to solve it in storyboard. Just drop a new View to your windows main view. Then drag the UIPageControl item to the new View. Now you can adjust the height of the new view as desired. The contained UIPageControl is clipped accordingly. Most properly you have to adjust the position of the UIPageControl inside the new view to get a proper display. Don't forget to set "Clip Subviews" for the new view.

upslupo
  • 21
  • 4
2

Drag UIView in your XIB, then change Its class to UIPageControl

user807146
  • 103
  • 8
0

This works for me, a little different code. It updates the view's frame property of your page control. I put this in the viewDidLoad method of my PageViewController.m file

self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 100);
MSU_Bulldog
  • 3,501
  • 5
  • 37
  • 73
0

For swift 4.2:

pageControl.frame = CGRect(x: desired x, y: desired y, width:  desired width, height:  desired height);
0

have you done tried like this?

UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(self.frame.size.width/2,  self.frame.size.height -20, (self.frame.size.width/nimages)/2, 20)];  
pageControl.numberOfPages=nimages;  
[pageControl setNeedsLayout];  
[self addSubview:pageControl];  
Nitish
  • 13,845
  • 28
  • 135
  • 263
-1

if you using interface builder, you can add new constrants for your UIPageControl.Like enter image description here enter image description here

i add a beautiful background color to make you see clearly.

Jack Shi
  • 1
  • 2