SlideController is simple and flexible UI component completely written in Swift. It is nice alternative for UIPageViewController built using power of generic types.
- iOS 9.0+
- Xcode 9.0+
- Swift 4.0+
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
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'SlideController'
end
Then, run the following command:
$ pod install
import SlideController
- Create content
let content = [
SlideLifeCycleObjectBuilder<PageLifeCycleObject>(),
SlideLifeCycleObjectBuilder<PageLifeCycleObject>(),
SlideLifeCycleObjectBuilder<PageLifeCycleObject>()
]
PageLifeCycleObject
is any object conforms toInitializable, Viewable, SlidePageLifeCycle
protocols
- Initialize SlideController
slideController = SlideController<CustomTitleView, CustomTitleItem>(
pagesContent: content,
startPageIndex: 0,
slideDirection: .horizontal
)
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:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
slideController.viewDidAppear()
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
slideController.viewDidDisappear()
}