📖 A simple, highly informative page view controller
Swift
2,050
1,073 commits
updated Sep 26, 2026
TL;DR UIPageViewController done properly.
Pageboy 5 requires iOS 14 / tvOS 14; and is compatible with Swift 6 (Xcode 16+).
Pageboy is compatible with Swift Package Manager and can be integrated via Xcode.
PageboyViewController and provide it with a PageboyViewControllerDataSource.class PageViewController: PageboyViewController, PageboyViewControllerDataSource {
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
}
}
PageboyViewControllerDataSource functions.func numberOfViewControllers(in pageboyViewController: PageboyViewController) -> Int {
return viewControllers.count
}
func viewController(for pageboyViewController: PageboyViewController,
at index: PageboyViewController.PageIndex) -> UIViewController? {
return viewControllers[index]
}
func defaultPage(for pageboyViewController: PageboyViewController) -> PageboyViewController.Page? {
return nil
}
The delegate functions provided by a PageboyViewController are much more reliable and useful than what a raw UIPageViewController provides. You can use them to find out exactly where the current page is, and when it's moved, where it's headed.
About to embark on a transition to a new page.
func pageboyViewController(_ pageboyViewController: PageboyViewController,
willScrollToPageAt index: Int,
direction: PageboyViewController.NavigationDirection,
animated: Bool)
Scrolled to a relative position along the way transitioning to a new page.
func pageboyViewController(_ pageboyViewController: PageboyViewController,
didScrollTo position: CGPoint,
direction: PageboyViewController.NavigationDirection,
animated: Bool)
Successfully completed a scroll transition to a page.
func pageboyViewController(_ pageboyViewController: PageboyViewController,
didScrollToPageAt index: Int,
direction: PageboyViewController.NavigationDirection,
animated: Bool)
Child view controllers have been reloaded.
func pageboyViewController(_ pageboyViewController: PageboyViewController,
didReloadWith currentViewController: UIViewController,
currentPageIndex: PageIndex)
You can navigate programmatically through a PageboyViewController using scrollToPage():
pageViewController.scrollToPage(.next, animated: true)
.isInfiniteScrollEnabled..isScrollEnabled.Pageboy provides the ability to insert and delete pages dynamically in the PageboyViewController.
func insertPage(at index: PageIndex, then updateBehavior: PageUpdateBehavior)
func deletePage(at index: PageIndex, then updateBehavior: PageUpdateBehavior)
This behaves similarly to the insertion of rows in UITableView, in the fact that you have to update the data source prior to calling any of the update functions.
Example:
let index = 2
viewControllers.insert(UIViewController(), at: index)
pageViewController.insertPage(at: index)
The default behavior after inserting or deleting a page is to scroll to the update location, this however can be configured by passing a PageUpdateBehavior value other than .scrollToUpdate.
reloadData() - Reload the view controllers in the page view controller. (Reloads the data source)..navigationOrientation - Whether to orientate the pages horizontally or vertically..currentViewController - The currently visible view controller if it exists..currentPosition - The exact current relative position of the page view controller..currentIndex - The index of the currently visible page..parentPageboy - Access the immediate parent PageboyViewController from any child view controller.Pageboy also provides custom transition support for animated transitions. This can be customized via the .transition property on PageboyViewController.
pageboyViewController.transition = Transition(style: .push, duration: 1.0)
Note: By default this is set to nil, which uses the standard animation provided by UIPageViewController.
PageboyAutoScroller is available to set up timer based automatic scrolling of the PageboyViewController:
pageboyViewController.autoScroller.enable()
Support for custom intermission duration and other scroll behaviors is also available.
Bug reports and pull requests are welcome on GitHub at https://github.com/uias/Pageboy.
The library is available as open source under the terms of the MIT License.
3,226 followers · starred Mar 2017
228 followers · starred Oct 2024
819 followers · starred Jan 2026
53 followers · starred Mar 2017
📖 A simple, highly informative page view controller
Swift
2,050
1,073 commits
updated Sep 26, 2026
TL;DR UIPageViewController done properly.
Pageboy 5 requires iOS 14 / tvOS 14; and is compatible with Swift 6 (Xcode 16+).
Pageboy is compatible with Swift Package Manager and can be integrated via Xcode.
PageboyViewController and provide it with a PageboyViewControllerDataSource.class PageViewController: PageboyViewController, PageboyViewControllerDataSource {
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
}
}
PageboyViewControllerDataSource functions.func numberOfViewControllers(in pageboyViewController: PageboyViewController) -> Int {
return viewControllers.count
}
func viewController(for pageboyViewController: PageboyViewController,
at index: PageboyViewController.PageIndex) -> UIViewController? {
return viewControllers[index]
}
func defaultPage(for pageboyViewController: PageboyViewController) -> PageboyViewController.Page? {
return nil
}
The delegate functions provided by a PageboyViewController are much more reliable and useful than what a raw UIPageViewController provides. You can use them to find out exactly where the current page is, and when it's moved, where it's headed.
About to embark on a transition to a new page.
func pageboyViewController(_ pageboyViewController: PageboyViewController,
willScrollToPageAt index: Int,
direction: PageboyViewController.NavigationDirection,
animated: Bool)
Scrolled to a relative position along the way transitioning to a new page.
func pageboyViewController(_ pageboyViewController: PageboyViewController,
didScrollTo position: CGPoint,
direction: PageboyViewController.NavigationDirection,
animated: Bool)
Successfully completed a scroll transition to a page.
func pageboyViewController(_ pageboyViewController: PageboyViewController,
didScrollToPageAt index: Int,
direction: PageboyViewController.NavigationDirection,
animated: Bool)
Child view controllers have been reloaded.
func pageboyViewController(_ pageboyViewController: PageboyViewController,
didReloadWith currentViewController: UIViewController,
currentPageIndex: PageIndex)
You can navigate programmatically through a PageboyViewController using scrollToPage():
pageViewController.scrollToPage(.next, animated: true)
.isInfiniteScrollEnabled..isScrollEnabled.Pageboy provides the ability to insert and delete pages dynamically in the PageboyViewController.
func insertPage(at index: PageIndex, then updateBehavior: PageUpdateBehavior)
func deletePage(at index: PageIndex, then updateBehavior: PageUpdateBehavior)
This behaves similarly to the insertion of rows in UITableView, in the fact that you have to update the data source prior to calling any of the update functions.
Example:
let index = 2
viewControllers.insert(UIViewController(), at: index)
pageViewController.insertPage(at: index)
The default behavior after inserting or deleting a page is to scroll to the update location, this however can be configured by passing a PageUpdateBehavior value other than .scrollToUpdate.
reloadData() - Reload the view controllers in the page view controller. (Reloads the data source)..navigationOrientation - Whether to orientate the pages horizontally or vertically..currentViewController - The currently visible view controller if it exists..currentPosition - The exact current relative position of the page view controller..currentIndex - The index of the currently visible page..parentPageboy - Access the immediate parent PageboyViewController from any child view controller.Pageboy also provides custom transition support for animated transitions. This can be customized via the .transition property on PageboyViewController.
pageboyViewController.transition = Transition(style: .push, duration: 1.0)
Note: By default this is set to nil, which uses the standard animation provided by UIPageViewController.
PageboyAutoScroller is available to set up timer based automatic scrolling of the PageboyViewController:
pageboyViewController.autoScroller.enable()
Support for custom intermission duration and other scroll behaviors is also available.
Bug reports and pull requests are welcome on GitHub at https://github.com/uias/Pageboy.
The library is available as open source under the terms of the MIT License.
3,226 followers · starred Mar 2017
228 followers · starred Oct 2024
819 followers · starred Jan 2026
53 followers · starred Mar 2017