Can we customize the page indicator in UIPageViewController?

后端 未结 11 1990
广开言路
广开言路 2020-12-07 17:30

Now it\'s white dots with black background. What about if I want it to be black dots with white backgrounds?

- (NSInteger)presentationCountForPageViewControl         


        
11条回答
  •  轮回少年
    2020-12-07 18:01

    It is possible to customise it through appearance. You can do it in AppDelegate like this.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
       UIPageControl *pageControl = [UIPageControl appearance];
       pageControl.pageIndicatorTintColor = [UIColor whiteColor];
       pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
       pageControl.backgroundColor = [UIColor lightGrayColor];
    
       return YES;
    }
    

    If you want to do it just for a certain view controller, replace the pageControl with this instead.

    UIPageControl *pageControl = [UIPageControl appearanceWhenContainedIn:[MyViewController class], nil];
    

提交回复
热议问题