7

I've tried setting a UIPageControl frame to the full width of my screen and setting alignment in the Interface Builder to Horizontal: right but it remains as centred.

"contentVerticalAlignment" is a UIControl property and there's no mention of whether it will work for a UIPageControl in the docs. Is horizontal alignment supposed to work for a UIPageControl? If not shall I subclass it to make it work (by embedding it in a UIView and aligning it myself).

Bbx
  • 3,184
  • 3
  • 22
  • 33

3 Answers3

0

It's a workaround, but you can do a homegrown size to fit like this:

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

for a left aligned UIPageControl.

Johnny Rockex
  • 4,136
  • 3
  • 35
  • 55
0

Here's an updated workaround:

pager.frame.size.width = CGFloat(pager.numberOfPages) * 17 - 14
newit
  • 1
0

This works very well:

pager.frame.size.width = CGFloat(pager.numberOfPages - 1) * 16 + 7
nathan
  • 9,329
  • 4
  • 37
  • 51