OLManager
Overlay Manager 是一个轻量级、易于使用的、用 Swift 编写的辅助工具,它将为您提供方便的 API 来管理您的自定义覆盖周期,以避免代码重复。
示例
要运行示例项目,请克隆仓库,并首先从 Example 目录运行 pod install
。
要求
安装
OLManager 通过 CocoaPods 提供。要安装它,请简单地将以下行添加到您的 Podfile 中
pod 'OLManager'
实现示例
import OLManager
enum YourCustomOverlays: OverlayLevelHolder {
case successOverlay
case failurOverlay
var level: YourCustomOverlays {
switch self {
case .successOverlay:
return .global
case .failurOverlay:
return .local
}
}
}
final class OverlayFactoryImp: OverlayFactory {
func makeOverlayWith(type: YourCustomOverlays) -> UIView {
switch type {
...
}
}
}
final class OverlayManagerProvider {
static let provider = OverlayManagerProvider()
var overlayManager: OverlayManagerOf<OverlayFactoryImp>
init() {
let factory = OverlayFactoryImp()
overlayManager = OverlayManagerOf<OverlayFactoryImp>(factory: factory)
}
}
final class ViewController: BaseViewController {
let overlayManager = OverlayManagerProvider.provider.overlayManager
var overlayManageable: OverlayManageable?
// MARK: UserInteraction
@IBAction func testButtonAction(_ sender: Any) {
let location = PinningLocation(horizontalEdge: .left, verticalEdge: .top)
let config = OverlayDisplayConfiguration(animationType: .slide, pinningLocation: location)
overlayManageable = overlayManager.displayOverlay(OverlayViewType.'your overlay type', configuration: config)
}
}
作者
MaxOstPM, [邮箱地址删除]
许可证
OLManager 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。