Question

Im having a problem trying to change UIPageControl color of the dots after create a Page based template on xcode and just changing UIPageViewController transition style to Scroll.

The dots aren't appearing on view, i don't know why.

I've just changed that:

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];

And, on AppDelegate.m (didFinishLaunchingWithOptions):

UIPageControl *pageControl = [UIPageControl appearance];
pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
pageControl.backgroundColor = [UIColor whiteColor];

Any help, please?

Thanks.

Was it helpful?

Solution

It looks to me like you're on the right track. Using the appearance proxy should work. I do it like this and it works (do it in your AppDelegate, and do it before the interface appears):

UIPageControl* proxy = 
    [UIPageControl appearanceWhenContainedIn:[UIPageViewController class], nil];
[proxy setPageIndicatorTintColor:[UIColor lightGrayColor];
[proxy setCurrentPageIndicatorTintColor:[UIColor blackColor]];
[proxy setBackgroundColor:[UIColor whiteColor]];

You also must implement the two delegate methods:

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pvc {
    // ...
}

-(NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pvc {
    // ...
}

Otherwise, the UIPageControl will not appear!

Apart from that, I cannot see much difference between what you're doing and what I'm doing, but I know that my code does work. You can download and try it here:

https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch06p311pageController/ch19p626pageController/AppDelegate.m

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top