diff --git a/DLAutoSlidePageViewController.podspec b/DLAutoSlidePageViewController.podspec
index 67f391a..b3343ec 100644
--- a/DLAutoSlidePageViewController.podspec
+++ b/DLAutoSlidePageViewController.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'DLAutoSlidePageViewController'
- s.version = '1.1.0'
+ s.version = '1.2.0'
s.summary = 'An auto slide PageViewController.'
s.description = <<-DESC
diff --git a/Example/DLAutoSlidePageViewController/Base.lproj/Main.storyboard b/Example/DLAutoSlidePageViewController/Base.lproj/Main.storyboard
index 0df3c15..6e799e4 100644
--- a/Example/DLAutoSlidePageViewController/Base.lproj/Main.storyboard
+++ b/Example/DLAutoSlidePageViewController/Base.lproj/Main.storyboard
@@ -5,7 +5,6 @@
-
@@ -20,23 +19,13 @@
-
-
-
-
-
-
-
-
-
-
@@ -81,8 +70,5 @@
-
-
-
diff --git a/README.md b/README.md
index d979f03..4eab01d 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ pod "DLAutoSlidePageViewController"
To integrate using [Swift Package Manager](https://swift.org/package-manager/), add the following as a dependency to your Package.swift:
```Swift
-.package(url: "https://github.com/DeluxeAlonso/DLAutoSlidePageViewController.git", .upToNextMajor(from: "1.1.0"))
+.package(url: "https://github.com/DeluxeAlonso/DLAutoSlidePageViewController.git", .upToNextMajor(from: "1.2.0"))
```
## Usage
@@ -81,15 +81,20 @@ let pages = [firstVC, secondVC]
let pageViewController = DLAutoSlidePageViewController(pages: pages, configuration: CustomConfiguration())
```
-## Page control configuration
+## Available configuration properties
-You can also access the UIPageControl through the `pageControl` property.
+`DLAutoSlidePageViewController` can be customized via the following properties:
-```swift
-pageViewController.pageControl.currentPageIndicatorTintColor = UIColor.lightGray
-pageViewController.pageControl.pageIndicatorTintColor = UIColor.gray
-pageViewController.pageControl.backgroundColor = UIColor.clear
-```
+| 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. |
## Author
diff --git a/Sources/AutoSlideConfiguration.swift b/Sources/AutoSlideConfiguration.swift
index 1e10195..cd6eba7 100644
--- a/Sources/AutoSlideConfiguration.swift
+++ b/Sources/AutoSlideConfiguration.swift
@@ -9,12 +9,30 @@ import UIKit
public protocol AutoSlideConfiguration {
+ /// Time interval to be used for each page automatic transition.
var timeInterval: TimeInterval { get }
+
+ /// Styles for the page-turn transition.
var transitionStyle: UIPageViewController.TransitionStyle { get }
+
+ /// Orientations for page-turn transitions.
var navigationOrientation: UIPageViewController.NavigationOrientation { get }
+
+ /// Space between pages.
var interPageSpacing: Float { get }
+
+ /// Decides if page contron is going to be shown or not.
var hidePageControl: Bool { get }
+ /// The tint color to be used for the current page indicator.
+ var currentPageIndicatorTintColor: UIColor { get }
+
+ /// The tint color to be used for the page indicator.
+ var pageIndicatorTintColor: UIColor { get }
+
+ /// The background color to be used for the page control.
+ var pageControlBackgroundColor: UIColor { get }
+
}
// MARK: - Default values
@@ -27,4 +45,8 @@ public extension AutoSlideConfiguration {
var interPageSpacing: Float { 0.0 }
var hidePageControl: Bool { false }
+ var currentPageIndicatorTintColor: UIColor { UIColor.gray }
+ var pageIndicatorTintColor: UIColor { UIColor.lightGray }
+ var pageControlBackgroundColor: UIColor { UIColor.clear }
+
}
diff --git a/Sources/DLAutoSlidePageViewController.swift b/Sources/DLAutoSlidePageViewController.swift
index c816234..d5399ce 100644
--- a/Sources/DLAutoSlidePageViewController.swift
+++ b/Sources/DLAutoSlidePageViewController.swift
@@ -19,26 +19,12 @@ open class DLAutoSlidePageViewController: UIPageViewController {
fileprivate var transitionInProgress: Bool = false
fileprivate var shouldHidePageControl: Bool = false
+ // MARK: - Computed properties
+
public var pageControl: UIPageControl? {
return UIPageControl.appearance(whenContainedInInstancesOf: [UIPageViewController.self])
}
- // MARK: - Lifecycle
-
- deinit {
- stopTimer()
- NotificationCenter.default.removeObserver(self,
- name: UIApplication.willEnterForegroundNotification,
- object: nil);
- }
-
- override open func viewDidLoad() {
- super.viewDidLoad()
- delegate = self
- dataSource = self
- setupObservers()
- }
-
// MARK: - Initializers
public convenience init(pages: [UIViewController],
@@ -51,7 +37,8 @@ open class DLAutoSlidePageViewController: UIPageViewController {
self.shouldHidePageControl = configuration.hidePageControl
setupPageView()
- setupPageControl()
+ setupPageTimer(with: timeInterval)
+ setupPageControl(with: configuration)
}
public convenience init(pages: [UIViewController],
@@ -66,7 +53,24 @@ open class DLAutoSlidePageViewController: UIPageViewController {
self.timeInterval = ti
self.shouldHidePageControl = hidePageControl
setupPageView()
- setupPageControl()
+ setupPageTimer(with: timeInterval)
+ setupPageControl(with: DefaultAutoSlideConfiguration.shared)
+ }
+
+ // MARK: - Lifecycle
+
+ deinit {
+ stopTimer()
+ NotificationCenter.default.removeObserver(self,
+ name: UIApplication.willEnterForegroundNotification,
+ object: nil);
+ }
+
+ override open func viewDidLoad() {
+ super.viewDidLoad()
+ delegate = self
+ dataSource = self
+ setupObservers()
}
// MARK: - Private
@@ -82,11 +86,10 @@ open class DLAutoSlidePageViewController: UIPageViewController {
setViewControllers([firstPage], direction: .forward, animated: true, completion: nil)
}
- fileprivate func setupPageControl() {
- if self.timeInterval != 0.0 { setupPageTimer() }
- pageControl?.currentPageIndicatorTintColor = UIColor.gray
- pageControl?.pageIndicatorTintColor = UIColor.lightGray
- pageControl?.backgroundColor = UIColor.clear
+ fileprivate func setupPageControl(with configuration: AutoSlideConfiguration) {
+ pageControl?.currentPageIndicatorTintColor = configuration.currentPageIndicatorTintColor
+ pageControl?.pageIndicatorTintColor = configuration.pageIndicatorTintColor
+ pageControl?.backgroundColor = configuration.pageControlBackgroundColor
}
fileprivate func viewControllerAtIndex(_ index: Int) -> UIViewController {
@@ -95,7 +98,8 @@ open class DLAutoSlidePageViewController: UIPageViewController {
return pages[index]
}
- fileprivate func setupPageTimer() {
+ fileprivate func setupPageTimer(with timeInterval: TimeInterval) {
+ guard timeInterval != 0.0 else { return }
timer = Timer.scheduledTimer(timeInterval: timeInterval,
target: self,
selector: #selector(changePage),
@@ -110,9 +114,8 @@ open class DLAutoSlidePageViewController: UIPageViewController {
}
fileprivate func restartTimer() {
- guard timeInterval != 0.0 else { return }
stopTimer()
- setupPageTimer()
+ setupPageTimer(with: timeInterval)
}
// MARK: - Selectors