DevOptions
示例
要运行示例项目,请先克隆仓库,然后从Example目录中运行pod install
。
要求
- iOS 9.0+
- 位于目标Pod目录中的文件“Pods-acknowledgement.plist”。
安装
DevOptions可通过CocoaPods获取。要安装它,请简单地将以下行添加到Podfile中:
pod 'DevOptions'
用法
-
将“Pods-acknowledgement.plist”文件添加到您的项目中。您可以在目标(Pods -> Target Support Files -> Pods-您的目标)的Pods目录中找到此文件。请确保文件位于您的目标项目中的“复制包资源”中。注意:在未来的版本之前,每次更新您的Pods时,您都需要手动执行此操作。
-
在AppDelegate的didFinishLaunchingWithOptions中配置Pod
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let configurations = DevOptionsConfigurations()
configurations.companyLogo = UIImage(named: "company_logo")
configurations.companyWebsite = "https://www.nomadesolutions.com/"
configurations.password = "1234"
//configurations.mainStoryboardName = "Main" //In case you use storyboards
//Other configurations are already set, but available for customization
DevOptions.configure(configurations, baseUrls: [UIApplication.serverBaseUrl(), UIApplication.otherBaseUrl()]) {
/*
What you want to do when the Developper Mode is activated or deactivated
*/
// To update DevOptions view controller.
DevOptions.baseUrls = [UIApplication.serverBaseUrl(), UIApplication.otherBaseUrl()]
}
return true
}
- 将EndorsementView添加到您的UI中
以编程方式
let endorsementView = EndorsementView()
view.addSubview(endorsementView)
endorsementView.snp.makeConstraints { (make) in
make.left.equalTo(view.snp.left)
make.right.equalTo(view.snp.right)
make.bottom.equalTo(view.snp.bottom)
}
或
let endorsementView = EndorsementView(CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 60))
view.addSubview(endorsementView)
从Storyboard中:为您的视图设置一个自定义类(类:EndorsementView,模块:DevOptions)。XCode应自动选择模块。
- 确保在ViewDidLoad中设置您的本地化文本,以及可选的页面标签。
override func viewDidLoad() {
super.viewDidLoad()
title = NSLocalizedString("welcome.navigation_bar.title", comment: "")
pageTag = "welcome"
let informationLabel = UILabel()
informationLabel.text = NSLocalizedString("welcome.label.information", comment: "")
//...
settingsButton = UIButton(type: .system)
settingsButton.setTitle(NSLocalizedString("welcome.button.settings", comment: ""), for: .normal)
//...
}
- 通过长按公司和许可证徽标访问DevOptions。
作者
Nomade Solutions Mobiles, [email protected]
授权
DevOptions在MIT授权下可用。有关更多信息,请参阅LICENSE文件。