LeeroySDK-iOS
LeeroySDK-iOS 为开发者提供了一套实用的 iOS 库,它包括快速实现 Leeroy 身份验证的方法、一组用户界面组件以及一些通用调试工具。
功能
- 支持设备注册。
- 支持用户登录。
- 支持自定义 UI 组件。
- 支持日志打印。
- 支持帧率显示。
- 计划支持自动刷新访问令牌。
- 计划支持打印机设置。
- 计划支持内存打印。
要求
- iOS 10 +
- Xcode 11 +
安装
您可以通过多种方式安装 LeeroySDK-iOS
CocoaPods
CocoaPods是一种方便安装LeeroySDK-iOS的方法。
- 将以下pod添加到您的
Podfile
platform :ios, '10.0'
target 'Your App' do
pod 'LeeroySDK-iOS'
end
- 然后,运行以下命令
$ pod install
- 切换到
编译阶段
,在编辑器的左上角点击+
添加一个新运行脚本阶段
。添加以下命令以解决App Store提交问题。
bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/LeeroyAuthKit.framework/strip-frameworks.sh"
如果您只使用LeeroyAuthKit,只需简单地将以下行添加到您的Podfile中
pod 'LeeroySDK-iOS/AuthKit'
如果您只使用LeeroyUIKit,只需简单地将以下行添加到您的Podfile中
pod 'LeeroySDK-iOS/UIKit'
如果您只使用LeeroyUtilityKit,只需简单地将以下行添加到您的Podfile中
pod 'LeeroySDK-iOS/UtilityKit'
Carthage
即将推出。
手动安装
- 将Leeroy框架添加到您的目标的
嵌入二进制文件
LeeroyAuthKit.framework
LeeroyUIKit.framework
LeeroyUtilityKit.framework
- 确保您链接以下
链接的框架和库
LeeroyAuthKit.framework
LeeroyUIKit.framework
LeeroyUtilityKit.framework
LeeroyAuthKit的使用
Leeroy身份验证实现的示例
LeeroyAuthInterface.shared.setup(with: .kds, environment: .dev, firebaseToken: { token in
FireStoreAuthManager.shared.authenticate(with: token) { result in
switch result {
case .error: NotificationCenter.default.post(name: LeeroyAuthInterface.FirebaseSignInResult, object: false)
case .success: NotificationCenter.default.post(name: LeeroyAuthInterface.FirebaseSignInResult, object: true)
}
}
}, completion: {
self.navigateTo(viewController: MainVC())
})
DEBUG
模式下调用它。
打印调试信息,通常您只在#if DEBUG
LeeroyAuthInterface.debugEnabled = true
#endif
使用 LeeroyUIKit
如何使用 LeeroyButton 的示例。
lazy var presentVCButton: LeeroyButton = {
let button = LeeroyButton(title: "Present", textColor: LeeroyUIManager.shared.themeColorManager.textColor, backgroundColor: LeeroyUIManager.shared.themeColorManager.positiveColor, cornerRadius: 30, clickListener: { [weak self] sender in
self?.showSecondViewController()
})
return button
}()
如何使用 LeeroyImageButton 的示例。
lazy var closeButton: LeeroyImageButton = {
let buttonImage = UIImage(named: "close", in: Bundle.getBundle(), compatibleWith: nil)
let buttonSize = CGSize(width: 24, height: 24)
let button = LeeroyImageButton(image: buttonImage, size: buttonSize) { [weak self] sender in
self?.dismiss(animated: true, completion: nil)
}
return button
}()
如何使用 LeeroyImageView 的示例。
lazy var backgroundImageView = LeeroyImageView(image: UIImage(named: "background", in: Bundle.getBundle(), compatibleWith: nil))
如何使用 LeeroyLabel 的示例。
lazy var userLoginLabel = LeeroyLabel(text: Constants.Login.title)
如何使用 LeeroyTextField 的示例。
lazy var normalTextField: LeeroyTextField = {
let textField = LeeroyTextField(placeholderText: "a placeholder", cornerRadius: 15.0, changedListener: { [weak self] textField in
print(textField.text as Any)
})
textField.delegate = self
textField.autocapitalizationType = .allCharacters
return textField
}()
如何使用 LeeroyUIView 的示例。
private var backgroundView = LeeroyUIView(backgroundColor: .black, cornerRadius: 10.0)
示例如何使用 LeeroyProgressHUD。
LeeroyProgressHUD.shared.showHUD(to: self.view)
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
LeeroyProgressHUD.shared.hideHUD()
let vc = SecondViewController()
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)
}
自定义颜色和字体。
所有 LeeroyUIKit 组件都有默认颜色和字体设置,这些设置由 ThemeColorManager
和 ThemeFontManager
管理。
- 您的自定义 ThemeColorManager 必须符合
ThemeColorProtocol
协议。 - 您的自定义 ThemeFontManager 必须符合
ThemeFontProtocol
协议。
LeeroyUtilityKit 的使用
打印调试信息。
- 启用
Leeroy 打印
功能,通常您只在 DEBUG 模式下启用它。
#if DEBUG
LeeroyLog.debugEnabled = true
#endif
- 使用
Leeroy 打印
功能。
LeeroyLog.print("my printing")
显示 FPS,通常您只在 DEBUG 模式下调用它。
#if DEBUG
LeeroyFPS.shared.open(on: self.view)
#endif
使用闭包表达式显示 FPS,通常您只在 DEBUG 模式下调用它。
#if DEBUG
LeeroyFPS.shared.openWithHandler(on: self.view) { value in
print("FPS: \(value)")
}
#endif
将FPS标签移至视图的最顶层。
LeeroyFPS.shared.bringFpsLabel(toFront: self.view)
移除FPS。
LeeroyFPS.shared.close()