IOS UIPageControl HorizontalAlignment not working

I tried to set the UIPageControl frame to the full width of my screen and set the horizontal alignment in the interface builder: to the right, but it remains in the center.

"contentVerticalAlignment" is a UIControl property and does not mention whether it will work for UIPageControl in documents. Is horizontal alignment supposed to work for UIPageControl? If not, I have to subclass it to make it work (by embedding it in a UIView and aligning it).

+6
source share
3 answers

This is a workaround, but you can make the homegrown size to fit:

pager.frame = CGRectMake(20, 10, array.count*13, 30); 

to align the left edge of the UIPageControl.

0
source

Here's a workaround updated:

 pager.frame.size.width = CGFloat(pager.numberOfPages) * 17 - 14 
0
source

This works very well:

 pager.frame.size.width = CGFloat(pager.numberOfPages - 1) * 16 + 7 
0
source

Source: https://habr.com/ru/post/946860/


All Articles