Browse Source

撤销录制按钮重绘

harry 3 years ago
parent
commit
3673b5c193

+ 14 - 0
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -115,6 +115,9 @@ public class BFRecordScreenController: BFBaseViewController {
                 }
                 BFLog(1, message: "添加录音文件:\(model.startTime) -- \(model.endTime)")
                 sself.withDrawBtn.setTitle("撤销录制", for: .normal)
+                DispatchQueue.main.async {[weak self] in
+                    self?.changeWithDrawBtnLayout()
+                }
                 var event = sself.events.last
                 if event != nil {
                     event!.deletedVoices = deletedVoices
@@ -874,8 +877,10 @@ public class BFRecordScreenController: BFBaseViewController {
 
             if let event = events.last, event.type == 2 {
                 withDrawBtn.setTitle("撤销录制", for: .normal)
+                changeWithDrawBtnLayout()
             } else {
                 withDrawBtn.setTitle("撤销", for: .normal)
+                changeWithDrawBtnLayout()
             }
             searchStopAtRecordRange()
         }
@@ -1260,6 +1265,15 @@ public class BFRecordScreenController: BFBaseViewController {
     }
 
     // MARK: - 录音对应图像绘制
+    
+    // 撤销按钮修改title,重绘
+    func changeWithDrawBtnLayout() {
+        withDrawBtn.imageEdgeInsets = UIEdgeInsets(top: -withDrawBtn.imageView!.height, left: 0, bottom: 0, right: -withDrawBtn.titleLabel!.width)
+        withDrawBtn.titleEdgeInsets = UIEdgeInsets(top: withDrawBtn.titleLabel!.height + 2, left: -withDrawBtn.imageView!.width, bottom: 0, right: 0)
+        
+        withDrawBtn.setNeedsLayout()
+        withDrawBtn.layoutIfNeeded()
+    }
 
     func changeProgress(progress: Float) {
         if itemModels[currItemModelIndex].mediaType == .VIDEO {