a iOS permission manager writtern by Swift
在podfile
添加
pod 'PermissionDirector'
在cartfile
添加
github "SoolyChristy/PermissionDirector"
两种方式
package.swift
添加dependencies: [
.package(url: "https://github.com/SoolyChristy/PermissionDirector.git", from: "0.0.4")
]
if !PermissionDirector.isAuthorized(for: .camera) {
PermissionDirector.requestAuthorization(for: .camera) { (result) in
if result == .authorized {
print("camera permission has been authorized")
}
}
}
PermissionAlertProtocol
协议public protocol PermissionAlertProtocol: class {
/// 提供弹窗实例
///
/// - Parameter type: 权限类型
/// - Returns: 弹窗实例
init(type: PermissionType)
/// 展示弹窗
func show()
}
class PermissionHudView: UIView, PermissionAlertProtocol {
required init(type: PermissionType) {
super.init(frame: CGRect())
// 你的实现
}
func show() {
// 你的实现
}
}
PermissionDirector.alertType = PermissionHudView.self