Parcourir la source

Merge branch 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit
合并代码

jsonwang il y a 3 ans
Parent
commit
b31a06c6aa

+ 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()
         }
@@ -1261,6 +1266,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 {