Swiftpack.co - DeluxeAlonso/DLAutoSlidePageViewController as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by DeluxeAlonso.
DeluxeAlonso/DLAutoSlidePageViewController 2.0.1
Auto slide PageViewController written in Swift.
⭐️ 10
🕓 2 weeks ago
iOS
.package(url: "https://github.com/DeluxeAlonso/DLAutoSlidePageViewController.git", from: "2.0.1")

DLAutoSlidePageViewController

Version License Platform Swift 5

Demo

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

DLAutoSlidePageViewController requires iOS 12.0 and Swift 4.0 or above.

Installation

CocoaPods

PageViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "DLAutoSlidePageViewController"

Swift Package Manager

To integrate using Swift Package Manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/DeluxeAlonso/DLAutoSlidePageViewController.git", .upToNextMajor(from: "1.2.0"))

Usage

Create an instance of DLAutoSlidePageViewController and provide it with an array of UIViewController's.

let firstVC = storyboard?.instantiateViewController(withIdentifier: 'FirstVC')
let secondVC = storyboard?.instantiateViewController(withIdentifier: 'SecondVC')
let pages = [firstVC, secondVC]

let pageViewController = DLAutoSlidePageViewController(pages: pages)
                                                       
addChildViewController(pageViewController)
containerView.addSubview(pageViewController.view)
pageViewController.view.frame = containerView.bounds

Appearance and presentation configuration

There are two ways to configure the appearance and presentation of DLAutoSlidePageViewController:

  1. You can do it globally using the DefaultAutoSlideConfiguration class before instantiation.
let pages = [firstVC, secondVC]

DefaultAutoSlideConfiguration.shared.timeInterval = 5.0
DefaultAutoSlideConfiguration.shared.interPageSpacing = 3.0
DefaultAutoSlideConfiguration.shared.hidePageControl = false
let pageViewController = DLAutoSlidePageViewController(pages: pages)
  1. You can create your own configuration instance that conforms to AutoSlideConfiguration protocol and pass it on DLAutoSlidePageViewController's initializer.
struct CustomConfiguration: AutoSlideConfiguration {
    var timeInterval: TimeInterval = 10.0
    var navigationOrientation: UIPageViewController.NavigationOrientation = .vertical
}
let pages = [firstVC, secondVC]
let pageViewController = DLAutoSlidePageViewController(pages: pages, configuration: CustomConfiguration())

Available configuration properties

DLAutoSlidePageViewController can be customized via the following properties:

Property Type Description
timeInterval TimeInterval Time interval to be used for each page automatic transition.
transitionStyle UIPageViewController.TransitionStyle Styles for the page-turn transition.
navigationOrientation UIPageViewController.NavigationOrientation Orientations for page-turn transitions.
navigationDirection UIPageViewController.NavigationDirection Directions for page-turn transitions.
interPageSpacing Float Space between pages.
spineLocation UIPageViewController.SpineLocation Locations for the spine. Only valid if the transition style is UIPageViewController.TransitionStyle.pageCurl.
hidePageControl Bool Decides if page control is going to be shown or not.
currentPageIndicatorTintColor UIColor The tint color to be used for the current page indicator.
pageIndicatorTintColor UIColor The tint color to be used for the page indicator.
pageControlBackgroundColor UIColor The background color to be used for the page control.
shouldAnimateTransition Bool Indicates whether the automatic transition is to be animated.

Author

Alonso Alvarez, alonso.alvarez.dev@gmail.com

License

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

GitHub

link
Stars: 10
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Updates minimum iOS supported version
2 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics