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]; 
   }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容