FLOPageViewController is an easy to use page view controller for macOS, similar to
UIPageViewController for iOS. It uses
NSPageController under the hood, but is much simpler to use and provides customizable UI elements for navigation.
FLOPageViewController is a subclass of
NSViewController and NOT
NSPageController. Thus, you can use a
FLOPageViewController as your window's content view controller.
Basically, you just need to pass an array of
NSViewControllers to your
FLOPageViewController instance using the
If you're working with storyboards, you might want to use the
loadViewControllers(:from:) convenience method. It will load
NSViewControllers from an
NSStoryboard using the given
Behavior + Appearance
pageControl is visible by default and supports two different styles,
.circle. Set the
showPageControl property to
false in order to hide it. If you only want to show it when the mouse is inside, set the
pageControlRequiresMouseOver property to
To change the size, override the default value of
The arrow controls are hidden by default. Set the
showArrowControls property to
true in order to show them. Arrows will be hidden automatically depending on if there is a previous/next page. If you only want to show them when the mouse is inside, set the
arrowControlsRequireMouseOver property to
To change the size, change the
ArrowSize constant in
FLOPageViewController.swift. To change the thickness, override the default value of
By default, all controls will appear above the pages. You can change this behavior by setting the
overlayControls property to
false. If you do this, you may want to read the
pageSize property to be able to size your pages appropriately.
tintColor property controls the color of the page indicators and arrow controls. This color should have an alpha value of
backgroundColor property is the color displayed behind the pages. By default, no color is being displayed.
NSPageController under the hood, swipe gestures are supported by default.
Requirements + Compatibility
FLOPageViewController requires Swift 4.0. It is compatible with macOS 10.10 and later. I've tested it on 10.10, 10.11, 10.12 and 10.13.
Download the repository, build the Xcode project and add the
FLOPageViewController.framework build product to your project.
FLOPageViewController supports R-L languages out of the box. In case of an R-L language, the
viewControllers array will be reversed and the
selectedPagewill be set to the last index.
- Support for varying page sizes
- Accessibility support
- UI tests
- Properties to change the appearance of the navigation controls
Feel free to create pull requests based on this list or suggest even more improvements.
FLOPageViewController is available under the MIT license. See the LICENSE file for more info.