Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide UIPageControl of UIPageControlViewController on certain page index

I want to hide the page control indicator on a certain VC and instead show a button with the text 'Get started'. The user has however still be able to navigate back into the page control.

I've tried this:

self.pageController = [UIPageControl appearance];
self.pageController.pageIndicatorTintColor = [UIColor redColor];
self.pageController.currentPageIndicatorTintColor = [UIColor greenColor];

if(self.pageIndex == 1){
    self.pageController.hidden = YES;
    NSLog(@"hide you!");
}

However, this doesn't work. setting self.pageController.hidden = YES without the if statement works, and the nslog is triggered as well. It seems that somehow this can only be set once.

I also don't know how smooth this will be. I obviously don't want it to change when the user is fully arrived on the page itself, but in the transition toward it.

What is the best way to tackle this problem?

like image 470
bdv Avatar asked Oct 28 '25 08:10

bdv


1 Answers

I made it with swift, maybe it will help -

func setPageControlHidden (hidden: Bool)
{
    for subView in self.view.subviews
    {
        if subView is UIScrollView
        {
            subView.frame = self.view.bounds
        }
        else if subView is UIPageControl
        {
            subView.hidden = hidden
        }
    }
}
like image 105
Idan Yehuda Avatar answered Oct 30 '25 00:10

Idan Yehuda