APPagedScrollViewController
public class APPagedScrollViewController: UIViewController, APPagedScrollViewDelegate, APPagedScrollViewDataSource
A utility view controller class that lets you easily setup APPagedScrollView for an entire view controller, providing automatic layout and page control support.
-
The internal paged scroll view.
Declaration
Swift
var scrollView = APPagedScrollView()
-
Align the current page of the scroll view to the closest or most appropriate one.
If you have a view controller that could rotate, implement this method in your UIViewController’s viewWillTransition(to:, with:) and pass along the coordinator so that we can adjust the scroll view’s page for rotations.
Declaration
Swift
public func alignScrollView(with coordinator: UIViewControllerTransitionCoordinator? = nil)Parameters
coordinatorSpecify a transition coordinator to animate alongside, making it look seamless for events like device rotations or animated view size changes.
-
Reloads the pages of the scroll view.
Declaration
Swift
public func reloadData() -
The index of the current page.
Declaration
Swift
public var currentPageIndex: Int -
Scrolls to the page with the provided index.
Declaration
Swift
public func scroll(to index: Int, animated: Bool)Parameters
indexThe index of the page to scroll to.
animatedWhether or not to animate this change.
-
Scroll forward one page, if possible.
Declaration
Swift
public func goForward(animated: Bool = true) -
Scroll back one page, if possible.
Declaration
Swift
public func goBack(animated: Bool = true) -
The number of pages within this scroll view.
Declaration
Swift
public var numberOfPages: Int -
Register a page control with the paged scroll view controller so that it automatically changes to match the current page and number of pages correctly.
This will also add an event listener so that taps to the page control automatically control the current page index of the scroll view.
Declaration
Swift
public var pageControl: UIPageControl? -
Whether or not to have movedTo: events include elastic scrolling
Declaration
Swift
public var elasticScrollingEvents: Bool
-
Called when the scroll view has moved to a new page.
Declaration
Swift
public func pagedScrollView(_ pagedScrollView: APPagedScrollView, movedTo index: Int, from oldIndex: Int?)Parameters
pagedScrollViewThe scroll view that has moved.
indexThe index of the page that the scroll view has moved to.
-
Called during the transition between two pages inside the scroll view.
Declaration
Swift
public func pagedScrollView(_ pagedScrollView: APPagedScrollView, movingTo index: Int, from oldIndex: Int, progress: CGFloat)Parameters
pagedScrollViewThe scroll view that has moved.
newIndexThe index of the page that the scroll view is moving to.
oldIndexThe index of the page that the scroll view is moving from.
progressThe progress of the transition as a value from 0.0 to 1.0.
-
Asks the data source to return the number of pages in the scroll view.
Declaration
Swift
public func numberOfPages(in pagedScrollView: APPagedScrollView) -> IntParameters
pagedScrollViewThe scroll view to return the amount of pages for.
Return Value
The number of pages in the scroll view.
-
Asks the data source to return the page view for the provided index in the scroll view.
Declaration
Swift
public func view(forPageAt index: Int, in pagedScrollView: APPagedScrollView) -> UIViewParameters
indexThe index of the page view to return.
pagedScrollViewThe scroll view to return the amount of pages for.
Return Value
The page view for the provided index in the scroll view.
View on GitHub
APPagedScrollViewController Class Reference