是否可以在页面视图控制器本机指示器上添加自定义图像页面指示器?

时间:2016-12-02 04:45:39

标签: ios objective-c iphone uipageviewcontroller

是否可以在页面视图控制器本机指示符上添加自定义图像页面指示符?

如果可能,请帮我怎么做?

this is the reference image not the actual one

2 个答案:

答案 0 :(得分:0)

If you normally want to change color of indicator then you can change directly color there is no need to change image by this way

let pageVC = UIPageControl()
pageVC.currentPageIndicatorTintColor = UIColor.red
pageVC.tintColor = UIColor.green

But you want to change the image of PageIndicator then try this link:-

Answer with GrayPageControl:- Is there a way to change page indicator dots color

It is really good and reliable.I also have used this code.

You might have to do some more customization as

-(void) updateDots
{
    for (int i = 0; i < [self.subviews count]; i++)
    {
        UIImageView* dot = [self.subviews objectAtIndex:i];

        if (i == self.currentPage) {
            if(i==0) {
                dot.image = [UIImage imageNamed:@"activesearch.png"];
            } else {
                dot.image = activeImage;
            }        
        } else {
            if(i==0) {
                dot.image = [UIImage imageNamed:@"inactivesearch.png"];
            } else {
                dot.image = inactiveImage;
            }
        }
    }
 }

Hope it will help you

答案 1 :(得分:0)

If you have page control ref then use

   let pageControl = UIPageControl.appearanceWhenContainedInInstancesOfClasses([ViewController.self])
   pageControl.pageIndicatorTintColor = UIColor.lightGrayColor()
   pageControl.currentPageIndicatorTintColor = UIColor.darkGrayColor()