修改系统UIPageControl的大小和颜色

创建控件继承于UIPageControl 然后再.m文件重写方法:

//重写方法 改变点点的大小
- (void) setCurrentPage:(NSInteger)page
{
    [super setCurrentPage:page];
    
    self.backgroundColor = [UIColor clearColor];
    for (NSUInteger subviewIndex = 0; subviewIndex < [self.subviews count]; subviewIndex++)
    {
        UIImageView* subview = [self.subviews objectAtIndex:subviewIndex];

        if (subviewIndex == page)
        {
            subview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"img_dangqian"]];
            CGSize size;
            size.height = 5;
            size.width = 5;
            [subview setFrame:CGRectMake(subview.frame.origin.x,
                                         subview.frame.origin.x,
                                         size.width,
                                         size.height)];
            
        }
        else
        {
            CGSize size;
            size.height = 5;
            size.width = 5;
            [subview setFrame:CGRectMake(subview.frame.origin.x,
                                         subview.frame.origin.x,
                                         size.width,
                                         size.height)];
            subview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"img_qita"]];
            
        }
        
    }
}

你可能感兴趣的:(修改系统UIPageControl的大小和颜色)