iOS UIPageControl的操作,设置圆点大小,显示图片等

1.修改大小,创建一个类,继承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)];

        

    }

}

2.如果只改变当前选中的点的大小,前面加个判断就可以了:

- (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)];

        }

        

    }

}

3.将点显示成图片的方法

[pageCon setValue:[UIImage imageNamed:@"BluePoint.png"] forKeyPath:@"_currentPageImage"];

 [pageCon setValue:[UIImage imageNamed:@"black"] forKeyPath:@"_pageImage"];

4.设置点的颜色的方法

pageCon.pageIndicatorTintColor = [UIColor blackColor];

pageCon.currentPageIndicatorTintColor = [UIColor redColor];

 

转载于:https://www.cnblogs.com/cui-cui/p/6474522.html

你可能感兴趣的:(iOS UIPageControl的操作,设置圆点大小,显示图片等)