Storyboardable
我想简单地使用 storyboard。
示例
要运行示例项目,请先克隆存储库,然后从Example目录运行pod install
。
需求
安装
Storyboardable可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中
pod 'Storyboardable'
作者:
作者outofcoding, [email
protected] 和 bear, [email
protected]
许可
Storyboardable可在MIT许可证下获得。有关更多信息,请参阅LICENSE文件。
使用。
枚举案例
创建一个继承自Storyboardable的枚举。案例是Storyboard文件标识Storyboard ID。
enum Main : Storyboardable {
case first
case second
case test
}
使用代码
// Get storyboard
let storyboard = Main.storyboard
print("storyboard = \(storyboard)")
// Use storyboard initial ViewController
let initial = Main.initial!
present(initial, animated: true, completion: nil)
// Use storyboard identifier ViewController
let first = Main.first.get
present(first, animated: true, completion: nil)
// Get Information
let test = Main.test
let name = test.name
let identifier = test.identifier ?? "none"
print("name = \(name), identifier = \(identifier)")
// Direct push or present
Main.test.present(self)
Main.test.push(self)
构建案例
使用代码
let builder = StoryboardBuilder(name: "Main")
let initController = builder.get("test")!
present(initController, animated: true, completion: nil)
let secondController = builder.get("second")!
present(secondController, animated: true, completion: nil)