Coder Social home page Coder Social logo

vincentneo / flopageviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from floschliep/flopageviewcontroller

0.0 1.0 0.0 267 KB

Easy to use Page View Controller for macOS (UIPageViewController for Mac)

License: MIT License

Swift 98.10% Objective-C 1.90%

flopageviewcontroller's Introduction

FLOPageViewController

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.

Usage

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 viewControllers property. 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 identifiers array.

Behavior + Appearance

Page Control

The pageControl is visible by default and supports two different styles, .dot and .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 true.

To change the size, override the default value of indicatorSize in FLOPageControl.swift.

Arrow Controls

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 true.

To change the size, change the ArrowSize constant in FLOPageViewController.swift. To change the thickness, override the default value of lineWidth in FLOArrowControl's draw(:) method.

Overlay

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.

Colors

The tintColor property controls the color of the page indicators and arrow controls. This color should have an alpha value of 1.0.

The (optional) backgroundColor property is the color displayed behind the pages. By default, no color is being displayed.

Gestures

As FLOPageViewController uses 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.

Installation

Download the repository, build the Xcode project and add the FLOPageViewController.framework build product to your project.

Localization

FLOPageViewController supports R-L languages out of the box. In case of an R-L language, the viewControllers array will be reversed and the pageControl's selectedPagewill be set to the last index.

To Do

  • 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.

Contact

Florian Schliep

License

FLOPageViewController is available under the MIT license. See the LICENSE file for more info.

flopageviewcontroller's People

Contributors

floschliep avatar xiao99xiao avatar felixlisczyk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.