#define dotW 4.5
#define activeDotW 6
#define magrin 5
重写UIPagecontrol类,添加下面方法根据需求修改间距
- (void)layoutSubviews
{
[super layoutSubviews];
//计算圆点间距
CGFloat marginX = dotW + magrin - 1;
//计算整个pageControll的宽度
CGFloat newW = (self.subviews.count - 1 ) * marginX;
//设置新frame
self.frame = CGRectMake(SCREEN_WIDTH - newW - 20, self.frame.origin.y, newW, self.frame.size.height);
//设置居中
// CGPoint center = self.center;
// center.x = self.superview.center.x;
// self.center = center;
//遍历subview,设置圆点frame
for (int i=0; i<[self.subviews count]; i++) {
UIImageView* dot = [self.subviews objectAtIndex:i];
if (i == self.currentPage) {
[dot setFrame:CGRectMake(i * marginX, dot.frame.origin.y, dotW, dotW)];
}else {
[dot setFrame:CGRectMake(i * marginX, dot.frame.origin.y, dotW, dotW)];
}
}
}