代码之家  ›  专栏  ›  技术社区  ›  Neru

pageIndicatorUIPageControl中的TintColor在iOS7中保持半透明白色

  •  4
  • Neru  · 技术社区  · 11 年前

    有人知道为什么在UIPageControl中设置pageIndicatorTintColor中的颜色在iOS7中不起作用吗?这是我设置此属性的代码行(self是UIPageControl):

    [self setPageIndicatorTintColor:[UIColor greenColor]];
    

    我查看了iOS开发者库,对该属性的描述似乎与几周前相同。会是苹果的缺陷吗?知道怎么修吗?然而,在iOS6上仍然运行良好。

    2 回复  |  直到 11 年前
        1
  •  14
  •   danylokos    11 年前

    有同样的问题,通过改变方法的顺序来解决这个问题,首先你需要设置numberOfPages,并且只有在该tintColor之后:

    之前:

    UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame: ...
    pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
    pageControl.pageIndicatorTintColor = [UIColor grayColor];
    pageControl.numberOfPages = 5;
    

    现在:

    UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame: ...
    pageControl.numberOfPages = 5;
    pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
    pageControl.pageIndicatorTintColor = [UIColor grayColor];
    
        2
  •  1
  •   Anton Tropashko    7 年前

    这很愚蠢:在我的例子中,UIPageControl的alpha是0.54,而不是1。