SlideController is a simple and flexible UI component fully written in Swift. Built using power of generic types, it is a nice alternative to UIPageViewController.
Requirements
- iOS 9.0+
- Xcode 10.2+
- Swift 5.0+
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate SlideController into your Xcode project using CocoaPods, specify it in your Podfile
:
Then, run the following command:
$ pod install
Usage
- Create content
PageLifeCycleObject
is any object conforms toInitializable, Viewable, SlidePageLifeCycle
protocols
- Initialize SlideController
CustomTitleView
is subclass ofTitleScrollView<CustomTitleItem>
CustomTitleItem
is subclass ofUIView
and conforms toInitializable, ItemViewable, Selectable
protocols
-
Add
slideController.view
to view hierarchy -
Call
slideController.viewDidAppear()
andslideController.viewDidDisappear()
in appropriate UIViewController methods:
Documentation
SlideController
Default initializer of SlideController
.
pagesContent
- initial content of controller, can be empty.
startPageIndex
- page index that should be displayed initially.
slideDirection
- slide direction. .horizontal
or .vertical
.
Returns titleView
instanсe of TitleScrollView
.
Returns LifeCycleObject
for currently displayed page.
Returns array of LifeCycleObject
that corresponds to SlideController
's content.
When set to true
unloads content when it is out of screen bounds. The default value is true
.
When set to true
scrolling in the direction of last item will result jumping to the first item. Makes scrolling infinite. The default value is false
.
If the value of this property is true
, content scrolling is enabled, and if it is false
, content scrolling is disabled. The default is true
.
Appends pages array of SlideLifeCycleObjectProvidable
to the end of sliding content.
Inserts SlideLifeCycleObjectProvidable
page object at index
in sliding content.
Removes a page at index
.
Slides content to page at pageIndex
with sliding animation if animated
is set to true
. Using forced
is not recommended, it will perform shift even if other shift animation in progress or pageIndex
equals current page. The default value of animated
is true
. The default value of forced
is false
.
Slides content the next page with sliding animation if animated
is set to true
. The default value of animated
is true
.
Lets the SlideController
know when it is displayed on the screen. Used for correctly triggering LifeCycle
events.
Lets the SlideController
know when it is not displayed on the screen. Used for correctly triggering LifeCycle
events.
TitleScrollView
Alignment of title view. Supports .top
, .bottom
, .left
, .right
. The default value of alignment
is .top
.
The size of TitleScrollView
. For .horizontal
slide direction of SlideController
the titleSize
corresponds to height
. For .vertical
slide direction of SlideController
the titleSize
corresponds to width
. The default value of titleSize
is 84
.
Array of title items that displayed in TitleScrollView
.