Onboard controler written in swift 3 that uses view controlers. By FrontFlip Studios
SwiftyOnboardVC is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SwiftyOnboardVC'
Then, run pod install
In case you haven't installed CocoaPods yet, run the following command
sudo gem install cocoapods
Drag the folder SwityOnboardVCSource
directory into your project.
- iOS 9.0+
- Xcode 8+
- Swift 3
Download and run the example project to see how SwiftyOnboardVC works.
Create an array of view controllers
if let storyboard = self.storyboard {
let viewOne = storyboard.instantiateViewController(withIdentifier: "ViewOne")
let viewTwo = storyboard.instantiateViewController(withIdentifier: "ViewTwo")
let viewThree = storyboard.instantiateViewController(withIdentifier: "ViewThree")
let viewFour = storyboard.instantiateViewController(withIdentifier: "ViewFour")
let viewControllers = [viewOne, viewTwo, viewThree, viewFour]
}
Create an instance of SwiftyOnboardVC with or without an array of view controllers
//Without view controllers
let onboard = SwiftyOnboardVC()
//with view controllers
let onboard = SwiftyOnboardVC(viewControllers: viewControllers)
If you create an instance without an array of view controllers set it
onboard.viewControllers = [viewOne, viewTwo, viewThree, viewFour]
Set some settings for SwiftyOnboardVC
onboard.backgroundColor = .black
Present SwiftyOnboardVC
self.present(onboard, animated: true, completion: nil)
You can get a handle on SwiftyOnboardVC control in any of your view controler classes
//Get the parent view controler which is SwiftyOnboardVC
if let parentVC = self.parent as? SwiftyOnboardVC {
//Then do whatever you like with the parent view controler
parentVC.dismiss(animated: true, completion: nil)
}
Once an instance has been created of SwiftyOnboardVC you can changed all of theses features
//view settings
onboard.backgroundColor = .white
onboard.bounces = true
onboard.showHorizontalScrollIndicator = false
//Page control settings
onboard.showPageControl = true
onboard.pageControlTintColor = .lightGray
onboard.currentPageControlTintColor = .black
//Left button settings
onboard.showLeftButton = true
onboard.leftButtonText = "Previous"
onboard.leftButtonTextColor = .black
onboard.leftButtonBackgroundColor = .orange
onboard.leftButtonCornerRadius = 0
onboard.leftButtonHeightPadding = 5
onboard.leftButtonWidthPadding = 5
//Right button settings
onboard.showRightButton = true
onboard.rightButtonText = "Next"
onboard.rightButtonTextColor = .black
onboard.rightButtonBackgroundColor = .orange
onboard.rightButtonCornerRadius = 0
onboard.rightButtonHeightPadding = 5
onboard.rightButtonWidthPadding = 5
//Button top margin
onboard.buttonTopMargin = 5
//Status bar
onboard.hideStatusBar = false
Theses are the functions you can call on the SwiftyOnboardVC controller
onboard.previousPage() //moves back to the previous page
onboard.nextPage() //moves to the next page
onboard.skip() //skips to the last page
onboard.moveLeftButtonOffScreen() //moves left button off screen
onboard.moveRightButtonOffScreen() //moves right button off screen
onboard.movePageControlOffScreen() //moves the page control off screen
onboard.moveLeftButtonOnScreen() //moves left button back on screen
onboard.moveRightButtonOnScreen() //moves right button back on screen
onboard.movePageControlOnScreen() //moves page control back on screen
onboard.updateView() //updates the view to give an animation to the buttons when they are moved.
Add SwiftyOnboardVCDelegate
to the top of your swift file and set the delegate
onboard.delegate = self
Once the delegate has been set you have theses optional functions
func leftButtonPressed() {
//Called when the left button is pressed
}
func rightButtonPressed() {
//Called when the right button is pressed
}
func pageDidChange(currentPage: Int) {
//Called when the page changes with the current page number. Here you can test the page number and hide/show the buttons and page control
}
If you would like to donate to make SwiftOnboardVC better or just buy me a beer.
- If you need help, use Stack Overflow. (Tag 'SwiftyOnboardVC')
- Or email myself at info@frontflipstudios.com.
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
SwiftyOnboardVC is available under the MIT license. See the LICENSE file for more info.