Search code examples
iosobjective-ciphoneuipageviewcontroller

Is it possible to add a custom image page indicator on a Page view Controller native indicator?


Is it possible to add a custom image page indicator on a Page view Controller native indicator?

If possible, help me how to do it ?

this is the reference image not the actual one


Solution

  • 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