|
@@ -8,6 +8,7 @@
|
|
|
class TSGennerateCellView: TSBaseView {
|
|
|
|
|
|
var refreshHandel:(()->Void)?
|
|
|
+ var longPressHandel:(()->Void)?
|
|
|
lazy var infoLabel: UILabel = {
|
|
|
let infoLabel = UILabel.createLabel(font: .font(size: 12),textColor: .themeColor,textAlignment: .center,numberOfLines: 0)
|
|
|
return infoLabel
|
|
@@ -37,9 +38,14 @@ class TSGennerateCellView: TSBaseView {
|
|
|
override func creatUI() {
|
|
|
backgroundColor = "#1D1812".uiColor
|
|
|
|
|
|
-
|
|
|
contentView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickContentView)))
|
|
|
+
|
|
|
|
|
|
+ let longPressRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(_:)))
|
|
|
+ longPressRecognizer.minimumPressDuration = 0.5 // 设置最小长按时间(秒)
|
|
|
+ contentView.addGestureRecognizer(longPressRecognizer)
|
|
|
+
|
|
|
+
|
|
|
contentView.addSubview(infoLabel)
|
|
|
infoLabel.snp.makeConstraints { make in
|
|
|
// make.top.equalTo(titleTop)
|
|
@@ -62,12 +68,21 @@ class TSGennerateCellView: TSBaseView {
|
|
|
make.centerY.equalToSuperview().offset(refreshBtn.isHidden ? 0 : -14.0)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private var isCanClick:Bool = false
|
|
|
+
|
|
|
@objc func clickContentView() {
|
|
|
if isCanClick{
|
|
|
refreshHandel?()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @objc func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
|
|
|
+ // 确保只在手势开始时触发一次
|
|
|
+ guard gestureRecognizer.state == .began else { return }
|
|
|
+ longPressHandel?()
|
|
|
+ }
|
|
|
+
|
|
|
func setProgress(progress:Float) {
|
|
|
refreshBtn.isHidden = true
|
|
|
isCanClick = false
|