UIPageControl如何改变点的大小

UIPageControl如何改变点的大小?

重写setCurrentPage方法即可:

- (void)setCurrentPage:(NSInteger)page {
   [super setCurrentPage:page]; 
   for (NSUInteger subviewIndex = 0; subviewIndex < [self.subviews count]; subviewIndex++) { 
        UIView *subview = [self.subviews objectAtIndex:subviewIndex];
        UIImageView *imageView = nil; 
        if (subviewIndex == page) {
              CGFloat w = 8;
              CGFloat h = 8;   
              imageView = [[UIImageView alloc] initWithFrame:CGRectMake(-1.5, -1.5, w, h)]; 
              imageView.image = [UIImage imageNamed:@"banner_red"];
              [subview setFrame:CGRectMake(subview.frame.origin.x, subview.frame.origin.y, w, h)]; 
        } else {
             CGFloat w = 5; 
             CGFloat h = 5; 
             imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, w, h)];
             imageView.image = [UIImage imageNamed:@"banner_gray"]; 
             [subview setFrame:CGRectMake(subview.frame.origin.x, subview.frame.origin.y, w, h)];
        } 
        imageView.tag = 10010; 
        UIImageView *lastImageView = (UIImageView *) [subview viewWithTag:10010];
         [lastImageView removeFromSuperview]; //把上一次添加的view移除 
         [subview addSubview:imageView]; 
   }
}

你可能感兴趣的:(UIPageControl如何改变点的大小)