SimpleWizzard 0.1.3

SimpleWizzard 0.1.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Higor Borjaille.



  • By
  • hborjaille

SimpleWizzard




alt text

Requirements

iOS 9+

Installation

SimpleWizzard is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SimpleWizzard"

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Code Examples

Creating a ViewController that will be encapsulated on SimpleWizzard

This controller needs to implement ChangeStepDelegate that will tell the Wizzard when to change the Step or not.

import SimpleWizzard

class SampleStepViewController: UIViewController, ChangeStepDelegate {

    func verifyNext() -> Bool {
        SampleWizardController.wizardInstance?.next()
        return false
    }
    
    func verifyPrev() -> Bool {
        return true
    }
}
There are two ways to use it

Return false into veryfyNext() function and force the changing

func verifyNext() -> Bool {
    SampleWizardController.wizardInstance?.next()
    return false
}

Or simply returning true on the function

func verifyNext() -> Bool {
    return true
}

The same applies for changing from current to previous ViewController.

Creating a ViewController extending from SimpleWizzardViewController

The created class has to implement CancelDelegate. This class will be responsible for canceling the wizzard progress. The user needs to instantiate every ViewController that it wants to use, before use the function generate.

import SimpleWizzard

class SampleWizardController: SimpleWizardViewController, CancelDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
        // Setting the Delegate Cancel
        self.cancelDelegate = self
        
        // Creating the steps
        var viewControllerList = [UIViewController]()
        
        let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
        for i in 0...5 {
            if let controller = mainStoryboard.instantiateViewController(withIdentifier: "sampleStepSID") as? SampleStepViewController {
                controller.pageNumberText = i.description
                viewControllerList.append(controller)
            }
        }
        
        // Setting the images
        self.nextImage = UIImage(named: "right")
        self.prevImage = UIImage(named: "left")
        self.doneImage = UIImage(named: "done_wizzard")
        
        // Setting the color of UIPageDots
        self.pageDots?.currentPageIndicatorTintColor = UIColor.black
        self.pageDots?.pageIndicatorTintColor = UIColor.lightGray
        
        // Generating the SimpleWizard
        self.generate(viewControllerList)
        
        // Setting Title
        self.title = "SimpleWizzard"
    }
    
    func cancel() {
        self.dismiss(animated: true, completion: nil)
    }
}

Author

Higor Borjaille

E-mail: [email protected]

License

SimpleWizzard is available under the MIT license. See the LICENSE file for more info.