思路是重写UIPageControl的setCurrentPage:方法, 代码如下:
1 /** 2 * 改变pageControl中点的大小 3 */ 4 - (void)setCurrentPage:(NSInteger)page { 5 [super setCurrentPage:page]; 6 for (NSUInteger subviewIndex = 0; subviewIndex < [self.subviews count]; subviewIndex++) { 7 UIImageView* subview = [self.subviews objectAtIndex:subviewIndex]; 8 CGSize size; 9 size.height = ZJHomeTopPageControlWH; 10 size.width = ZJHomeTopPageControlWH; 11 [subview setFrame:CGRectMake(subview.frame.origin.x, subview.frame.origin.y, size.width,size.height)]; 12 if (subviewIndex == page) { 13 [subview setBackgroundColor:self.currentPageIndicatorTintColor]; 14 } else { 15 [subview setBackgroundColor:self.pageIndicatorTintColor]; 16 } 17 } 18 }
时间: 2024-10-22 13:27:18