首页 > 代码库 > iOS 调整UIPageControl圆点大小
iOS 调整UIPageControl圆点大小
创建一个类,继承UIPageControl,重写setCurrentPage方法,可设置圆点大小
- (void) setCurrentPage:(NSInteger)page {
[super setCurrentPage:page];
for (NSUInteger subviewIndex = 0; subviewIndex < [self.subviews count]; subviewIndex++) {
UIImageView* subview = [self.subviews objectAtIndex:subviewIndex];
CGSize size;
size.height = 10;
size.width = 10;
[subview setFrame:CGRectMake(subview.frame.origin.x, subview.frame.origin.y,
size.width,size.height)];
}
}
如果只改变当前选中的点的大小,前面加个判断就可以了:
- (void) setCurrentPage:(NSInteger)page {
[super setCurrentPage:page];
for (NSUInteger subviewIndex = 0; subviewIndex < [self.subviews count]; subviewIndex++) {
if (subviewIndex == page)
{
UIImageView* subview = [self.subviews objectAtIndex:subviewIndex];
CGSize size;
size.height = 10;
size.width = 10;
[subview setFrame:CGRectMake(subview.frame.origin.x, subview.frame.origin.y,
size.width,size.height)];
}
}
}
iOS 调整UIPageControl圆点大小