Search code examples
iosswiftuipagecontrol

Increase spacing between indicator dots of UIPageControl


So I am working on customizing the UIPageControl (which Apple really doesn't make easy) and I'm wondering if there's a way to increase/decrease space between the indicator dots.

I've been using this code to get the UIPageControl

var pageControlMaybe: UIPageControl?

for (var i = 0; i < subviews.count; i++) {
    if (subviews[i] is UIPageControl) {
        pageControlMaybe = subviews[i] as? UIPageControl
        break
    }
}

But now I'm wondering if there's an easy way to change the spacing? I can resize the dots with a transform

pageControlMaybe?.transform = CGAffineTransformMakeScale(1.4, 1.4)

But this also increases the spacing between them. Ideally it would keep the dot size and just reduce the space between them.


Solution

  • As answered some other times there's no way to do this. I'd recommend you using 3rd party controls like FXPageControl and use this property:

    @property (nonatomic, assign) CGFloat dotSpacing;