CNLiveConfigAlertManager.swift
1.02 KB
//
// CNLiveConfigAlertManager.swift
// metaCode
//
// Created by open on 2023/11/1.
//
import Foundation
typealias resultActionAlertBlock = (_ index: Int) -> Void
class ConfigAlertManager: NSObject {
static let shared = ConfigAlertManager()
/// 自定义弹框
open func presentAlert(title: String, message: String, actionTitles: NSArray, resultBlock: @escaping resultActionAlertBlock) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
for title in actionTitles {
let style: UIAlertAction.Style
if title as! String == "取消" {
style = .cancel
} else {
style = .default
}
let action = UIAlertAction(title: title as? String, style: style) { action in
resultBlock(actionTitles.index(of: title))
}
alert.addAction(action)
}
currentViewController()?.present(alert, animated: true)
}
}