SimpleWizzard 0.1.3

SimpleWizzard 0.1.3

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2017年12月
SwiftSwift 版本3.0
SPM支持 SPM

Higor Borjaille 维护。



  • hborjaille

SimpleWizzard




alt text

需求

iOS 9+

安装

SimpleWizzard 通过 CocoaPods 提供。要安装它,只需在 Podfile 中添加以下行:
示例

pod "SimpleWizzard"

要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install

代码示例

创建一个将由 SimpleWizzard 封装的用户控制器

此控制器需要实现 ChangeStepDelegate 协议,该协议将在何时何时通知 Wizzard 改变步骤或保持不变。

使用它的有两种方式

import SimpleWizzard

class SampleStepViewController: UIViewController, ChangeStepDelegate {

    func verifyNext() -> Bool {
        SampleWizardController.wizardInstance?.next()
        return false
    }
    
    func verifyPrev() -> Bool {
        return true
    }
}
在 verifyNext() 函数中返回 false 强制改变

或者只简单地在该函数中返回 true

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

同样的方式也适用于从当前到上一个用户控制器的改变。

func verifyNext() -> Bool {
    return true
}

创建一个由 SimpleWizzardViewController 扩展的用户控制器

创建的类必须实现 CancelDelegate 协议。此类将负责取消向导进度。用户在使用 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)
    }
}

Higor Borjaille

电子邮件: [email protected]

SimpleWizzard 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。

许可证

CocoaPods 是以下项目的一个项目: