UIPageViewController with a last view without page indicator

168 views Asked by At

I would like to have 4 views that the user can swipe left or right. For this I am planning to use UIPageViewController.

What is special is that the last view should not have the page indicator at all. I would like to swipe it away with the view that is before the last one. Is this possible with UIPageViewController?

Here is a picture of a swipe moving to the last view:

enter image description here

2

There are 2 answers

1
dopcn On BEST ANSWER

I think that's impossible to achieve what you say with UIPageViewController. Because you can't get the value how far the current view is moved by now.

To get that value you can custom a UIScrollView and animate the page indicator yourself in the delegate method - scrollViewDidScroll:

0
AudioBubble On

There's no built-in support for conditionally showing the page control, depending on what page you're on.

  • If you could get the UIPageViewController to query its UIPageViewControllerDataSource, you could try returning 0 from presentationCountForPageViewController: while transitioning to the last view controller, but it will never be a good solution, as you're trying to circumvent what the controller is internally managing for you.
  • You can use UIAppearance to change the color of UIPageControl.

    This can be used to only apply a style for a particular view controller, as follows:

    UIPageControl *pageControl = [UIPageControl appearanceWhenContainedIn:[LastViewController class], nil];
    pageControl.pageIndicatorTintColor = [UIColor clearColor];
    pageControl.currentPageIndicatorTintColor = [UIColor clearColor];
    pageControl.backgroundColor = [UIColor clearColor];
    

    This, however, won't remove it from the view, and the page control's gestures would still be active.