UIPageControl的一些属性在ios6.0以下的使用

测试项目时,在ios5.1.1以下的设备上总是出现错误,错误信息如下:

[UIPageControl setCurrentPageIndicatorTintColor:]: unrecognized selector
                                        sent to instance

而ios6.0以上的设备就没问题。

经过查资料,才知道原来UIpageControl的currentPageIndicatorTintColor属性是在ios6.0以上的才有的。

查看苹果api文档,可知,currentPageIndicatorTintColor--》Available in iOS 6.0 and later.   

在ios6.0以下如果想改变小圆点的颜色,就得自己定义

double version = [[UIDevicecurrentDevice].systemVersiondoubleValue];

    if(version - 6.0 <= 1e-8)

    {

        [self updateDots];

    }

 

- (void) updateDots

{

if (imagePageStateNormal || imagePageStateHightlighted) {

NSArray *subView = [pageControl.subviews retain];

 

for (int i = 0; i < [subView count]; i++) {

UIImageView *dot = [subView objectAtIndex:i];

dot.image = (pageControl.currentPage == i ? imagePageStateHightlighted : imagePageStateNormal);

}

        

        [subView release];

}

}

在ios6.0以上如果想改变小圆点的颜色就可以直接使用

pageControl.currentPageIndicatorTintColor = [UIColorgreenColor];

pageControl.pageIndicatorTintColor = [UIColorgrayColor];

这两行代码来改变小圆点选中和未选中的颜色

原文地址:https://www.cnblogs.com/guatiantian/p/3421598.html