zoukankan      html  css  js  c++  java
  • 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];

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

  • 相关阅读:
    13 内建属性 _getattribute_ 内建函数
    12 垃圾回收GC
    11 元类
    12 动态语言 __slots__
    11 作用域
    10 带参数的装饰器 通用装饰器 类装饰器
    9 装饰器
    8 闭包
    6 生成器 yield 协程
    cmd常用命令
  • 原文地址:https://www.cnblogs.com/guatiantian/p/3421598.html
Copyright © 2011-2022 走看看