Lightbarrier Lightbarrier - 1 year ago 104
Objective-C Question

Changing UIPageViewController own PageController regarding Color of Dots

Hey I'm using a UIPageViewController to control what page I am on and for scrolling. I know it's possible to show a Page Controller along with it by simply adding the following two functions.

- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController

- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController

What I want to know is if it's possible to change the color of the page controller, so the dots are more visible on the background I'm using?

I know a regular page controller has the properties:

@property(nonatomic,retain) UIColor *currentPageIndicatorTintColor
@property(nonatomic,retain) UIColor *pageIndicatorTintColor

However, I can't figure out for the life of me how to access these properties or the Page Controller for that matter from UIPageViewController.

It might be helpful, if someone just said how to change the properties in general?

Answer Source

You can use UIAppearance to configure UIPageControl colors. This applies to UIPageControls in UIPageViewControllers too.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  UIPageControl *pageControl = [UIPageControl appearance];
  pageControl.pageIndicatorTintColor = [UIColor whiteColor];
  pageControl.currentPageIndicatorTintColor = [UIColor redColor];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download