To run the example project, clone the repo, and run pod install
from the Example directory first.
DLAutoSlidePageViewController requires iOS 10.0 and Swift 4.0 or above.
PageViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DLAutoSlidePageViewController"
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"))
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
There are two ways to configure the appearance and presentation of DLAutoSlidePageViewController
:
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)
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())
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. |
interPageSpacing | Float | Space between pages. |
hidePageControl | Bool | Decides if page contron 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. |
Alonso Alvarez, alonso.alvarez.dev@gmail.com
DLAutoSlidePageViewController is available under the MIT license. See the LICENSE file for more info.
link |
Stars: 10 |
Last commit: Yesterday |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco