// // MP_DownloadButton.swift // relax.offline.mp3.music // // Created by Mr.Zhou on 2024/9/29. // import UIKit import DownloadButton ///下载按钮 class MP_DownloadButton: PKDownloadButton { //特定的显示状态(一般是显示状态) private var isShow:Bool { if let statu = UserDefaults.standard.object(forKey: "isShowDownload") as? Bool { return statu }else { return true } } //内部调整的隐藏状态 private var _isHidden: Bool = false ///隐藏 override var isHidden: Bool{ set{ if isShow { //允许调整展示状态 _isHidden = newValue super.isHidden = newValue }else { //不允许调整 } } get { if isShow { //允许展示 return _isHidden }else { //不允许展示 startDownloadButton.isHidden = true downloadedButton.isHidden = true stopDownloadButton.isHidden = true pendingView.isHidden = true return true } } } override init(frame: CGRect) { super.init(frame: frame) } required init?(coder: NSCoder) { super.init(coder: coder) } }