杨锴
2025-04-16 09a372bc45fde16fd42257ab6f78b8deeecf720b
XQMuse/Root/Other/View/CommonAlertSheetView.swift
@@ -14,25 +14,36 @@
            @IBOutlet weak var tableView: UITableView!
            @IBOutlet weak var cons_tableHei: NSLayoutConstraint!
            @IBOutlet weak var cons_viewBottom: NSLayoutConstraint!
    @IBOutlet weak var cons_titleH: NSLayoutConstraint!
    @IBOutlet weak var view_title: UIView!
    @IBOutlet weak var label_title: UILabel!
            private var items = [String]()
            private var clouse:((Int)->Void)!
    private var hiddenTitle:Bool = false
            override func awakeFromNib() {
                        super.awakeFromNib()
                        alpha = 0
                        cons_viewBottom.constant = -JQ_ScreenW
                        layoutIfNeeded()
                        tableView.delegate = self
                        tableView.dataSource = self
                        tableView.separatorStyle = .none
        tableView.isScrollEnabled = false
                        tableView.register(CommonAlertSheetTCell.self, forCellReuseIdentifier: "TCell")
            }
            static func show(items:[String],clouse:@escaping (Int)->Void){
    static func show(title:String,items:[String],hiddenTitle:Bool = false,clouse:@escaping (Int)->Void){
                        let alertView = CommonAlertSheetView.jq_loadNibView()
        alertView.hiddenTitle = hiddenTitle
        alertView.label_title.text = title
        alertView.cons_titleH.constant = hiddenTitle ? 0:56
        alertView.view_title.isHidden = hiddenTitle
                        alertView.frame = sceneDelegate?.window?.frame ?? .zero
                        alertView.cons_tableHei.constant = CGFloat(items.count * 50)
                        alertView.cons_tableHei.constant = CGFloat(items.count * 56)
                        sceneDelegate?.window?.addSubview(alertView)
                        alertView.cons_viewBottom.constant = 0
                        alertView.items = items
@@ -48,7 +59,13 @@
            override func layoutSubviews() {
                        super.layoutSubviews()
                        let totalH = Double(items.count * 50) + UIDevice.jq_safeEdges.bottom + 50
        var totalH:Double = 0
        if hiddenTitle{
            totalH = Double(items.count * 56) + UIDevice.jq_safeEdges.bottom + 56.0
        }else{
            totalH = Double(items.count * 56) + UIDevice.jq_safeEdges.bottom + 56.0 + 56.0
        }
                        view_container.jq_addCorners(corner: [.topLeft,.topRight], radius: 20,height: totalH)
            }
@@ -82,11 +99,16 @@
            func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                        let cell = tableView.dequeueReusableCell(withIdentifier: "TCell") as! CommonAlertSheetTCell
                        cell.label_content.text = items[indexPath.row]
        if hiddenTitle{
            cell.label_content.textColor = UIColor(hexString: "#6B6B6B")
        }else{
            cell.label_content.textColor = UIColor(hexString: "#92A87D")
        }
                        return cell
            }
            func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
                        return 50
                        return 56
            }
}
@@ -100,8 +122,8 @@
                        selectionStyle = .none
                        label_content = UILabel()
                        label_content.text = "123"
                        label_content.font = UIFont.systemFont(ofSize: 16, weight: .medium)
                        label_content.textColor = .black.withAlphaComponent(0.8)
                        label_content.font = UIFont.systemFont(ofSize: 15, weight: .medium)
                        label_content.textColor = UIColor(hexString: "#6B6B6B")
                        contentView.addSubview(label_content)
                        label_content.snp.makeConstraints { make in
@@ -109,7 +131,7 @@
                        }
                        let lineView = UIView()
                        lineView.backgroundColor = UIColor(hexStr: "#DBDBE7")
                        lineView.backgroundColor = UIColor(hexStr: "#979797").withAlphaComponent(0.1)
                        contentView.addSubview(lineView)
                        lineView.snp.makeConstraints { make in
                                    make.left.equalTo(15)