Browse Source

Merge branch 'master' of https://git.yishihui.com/iOS/BFRecordScreenKit

wenweiwei 3 years ago
parent
commit
22d44ade84

BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/wordStyle1.imageset/wordStyle1.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/wordStyle1.imageset/wordStyle1@2x.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/wordStyle1.imageset/wordStyle1@3x.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/wordStyle5.imageset/wordStyle5.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/wordStyle5.imageset/wordStyle5@2x.png


BIN
BFRecordScreenKit/Assets/BFRecordScreenKit.xcassets/wordStyle5.imageset/wordStyle5@3x.png


+ 11 - 10
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -57,12 +57,7 @@ public class BFRecordScreenController: BFBaseViewController {
         }
     }
 
-    var isEndPlay = false {
-        didSet {
-            // 如果是图片的话在播放停止时不需要隐藏录制
-            recordBtn.isHidden = (itemModels[currItemModelIndex].mediaType == .IMAGE && isEndPlay) ? false : isEndPlay
-        }
-    }
+    var isEndPlay = false
 
     var isNormalPlaying = false { // 是否正在播放
         didSet {
@@ -181,7 +176,7 @@ public class BFRecordScreenController: BFBaseViewController {
     lazy var deleteRecordBtn: UIButton = {
         let btn = UIButton(type: .custom)
        
-        btn.backgroundColor =  UIColor.hexColor(hexadecimal: "#FF0000", alpha: 1)
+        btn.backgroundColor =  UIColor.hexColor(hexadecimal: "#FF0000", alpha: 0.3)
         btn.setTitle("删除录制", for: .normal)
         btn.adjustsImageWhenHighlighted = false
         btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 18)
@@ -1294,6 +1289,7 @@ public class BFRecordScreenController: BFBaseViewController {
 //                    isStopAtRecordRange = -1
 //                    BFLog(1, message: "停在了录音区间外 \(isStopAtRecordRange)")
                     searchStopAtRecordRange(needAdsorb: false)
+                    return
                 } else {
                     if fabs(elems[0].1.startCMTime.seconds - currentAssetProgress.seconds) < 0.5 {
                         BFLog(1, message: "吸附在录音开始")
@@ -1303,6 +1299,8 @@ public class BFRecordScreenController: BFBaseViewController {
                     }
                     deleteRecordBtn.isHidden = false
                     recordBtn.isHidden = true
+                    // add by ak 这里 isHidden 无效
+                    recordBtn.alpha = 0
                     isStopAtRecordRange = elems.first!.0
 
                     BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange), currTime:\(currentAssetProgress.seconds), 录音范围:\(elems[0].1.startCMTime.seconds) - \(elems[0].1.endCMTime.seconds)")
@@ -1310,6 +1308,7 @@ public class BFRecordScreenController: BFBaseViewController {
             } else {
                 deleteRecordBtn.isHidden = false
                 recordBtn.isHidden = true
+                recordBtn.alpha = 0
 
                 isStopAtRecordRange = elems.first!.0
                 BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange), currTime:\(currentAssetProgress.seconds), 录音范围:\(elems[0].1.startCMTime.seconds) - \(elems[0].1.endCMTime.seconds)")
@@ -1318,6 +1317,7 @@ public class BFRecordScreenController: BFBaseViewController {
         } else {
             deleteRecordBtn.isHidden = true
             recordBtn.isHidden = false
+            recordBtn.alpha = 1
 
             isStopAtRecordRange = -1
             BFLog(1, message: "停在了录音区间外 \(isStopAtRecordRange)")
@@ -1566,9 +1566,9 @@ public class BFRecordScreenController: BFBaseViewController {
         subtitleBtn.isHidden = false
         soundSettingBtn.isHidden = false
         withDrawBtn.isHidden = false
-        recordBtn.isHidden = isRecording ? false : isEndPlay
-        let su = isEndPlay
-        isEndPlay = su
+//        recordBtn.isHidden = isRecording ? false : isEndPlay
+        recordBtn.isHidden = (itemModels[currItemModelIndex].mediaType == .IMAGE && isEndPlay) ? false : isEndPlay
+
         assetPlayer?.pause()
         recordPlayer?.pause()
         recordStartPlayTime = CMTime.zero
@@ -1672,6 +1672,7 @@ public class BFRecordScreenController: BFBaseViewController {
 
             sself.isNormalPlaying = false
             sself.isEndPlay = true
+            sself.recordBtn.isHidden = (sself.itemModels[sself.currItemModelIndex].mediaType == .IMAGE) ? false : true
 
             sself.subtitleBtn.isHidden = false
             sself.soundSettingBtn.isHidden = false

+ 47 - 44
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleSettingView.swift

@@ -22,9 +22,7 @@ class BFSubtitleSettingView: UIView {
     var lastSelectStyleBtn: UIButton = UIButton()
     // 最后一次选择的位置 BTN
     var lastSelectPointBtn: UIButton = UIButton()
-    // 最后一次选择的字号的 BTN
-    var lastSelectwordSizeBtn: UIButton = UIButton()
-
+   
     var subtitleSettingCallBack: SubtitleSettingCallBack?
 
     var subtitle: PQEditSubTitleModel = PQEditSubTitleModel()
@@ -34,6 +32,12 @@ class BFSubtitleSettingView: UIView {
     
     //操作板背景
     let backView = UIButton()
+    
+    //设置字号配置位置
+    var wordSizeIndex:Int = 3
+    
+    var wordSizeBtnXiao:UIButton?
+    var wordSizeBtnDa:UIButton?
 
     override init(frame: CGRect) {
         super.init(frame: frame)
@@ -51,14 +55,16 @@ class BFSubtitleSettingView: UIView {
             make.height.equalTo(220)
         }
         backView.setNeedsUpdateConstraints()
+        
+        
 
-        styleConfig = [0: ["fontColor": UIColor.hexColor(hexadecimal: "#FFCF53"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       1: ["fontColor": UIColor.hexColor(hexadecimal: "#FF9292"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       2: ["fontColor": UIColor.hexColor(hexadecimal: "#80C2FF"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       3: ["fontColor": UIColor.hexColor(hexadecimal: "#80E4AB"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       4: ["fontColor": UIColor.hexColor(hexadecimal: "#FFFFFF"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0],
-                       5: ["fontColor": UIColor.hexColor(hexadecimal: "#000000"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.white, "backgroundAlpha": 0.0],
-                       6: ["fontColor": UIColor.hexColor(hexadecimal: "#FFFFFF"), "backgroundColor":UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.6), "strokeColor": UIColor.clear, "backgroundAlpha": 0.6]]
+        styleConfig = [0: ["fontColor": UIColor.hexColor(hexadecimal: "#FFFFFF"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":3.7,"subtitleSize":40],
+                       1: ["fontColor": UIColor.hexColor(hexadecimal: "#FF9292"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":4.3,"subtitleSize":49],
+                       2: ["fontColor": UIColor.hexColor(hexadecimal: "#80C2FF"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":5.2,"subtitleSize":60],
+                       3: ["fontColor": UIColor.hexColor(hexadecimal: "#80E4AB"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":5.8,"subtitleSize":69],
+                       4: ["fontColor": UIColor.hexColor(hexadecimal: "#FFCF53"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.black, "backgroundAlpha": 0.0,"strokeWidth":7.2,"subtitleSize":81],
+                       5: ["fontColor": UIColor.hexColor(hexadecimal: "#000000"), "backgroundColor": UIColor.clear, "strokeColor": UIColor.white, "backgroundAlpha": 0.0,"strokeWidth":8.7,"subtitleSize":101],
+                       6: ["fontColor": UIColor.hexColor(hexadecimal: "#FFFFFF"), "backgroundColor":UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.6), "strokeColor": UIColor.clear, "backgroundAlpha": 0.6,"strokeWidth":10.1,"subtitleSize":121]]
 
         // 字体样式
         for i in 0...6 {
@@ -143,6 +149,11 @@ class BFSubtitleSettingView: UIView {
             wordSizeBtn.addTarget(self, action: #selector(wordSizeSetting(sender:)), for: .touchUpInside)
             backView.addSubview(wordSizeBtn)
             wordSizeBtn.tag = i
+            if(i == 0){
+                wordSizeBtnXiao = wordSizeBtn
+            }else{
+                wordSizeBtnDa = wordSizeBtn
+            }
             
             wordSizeBtn.setBackgroundImage(imageInRecordScreenKit(by: i == 0 ? "wordSizeSetting-_h" : "wordSizeSetting+_h"), for: .normal)
  
@@ -223,6 +234,7 @@ class BFSubtitleSettingView: UIView {
         subtitle.setting.backgroundColor = config?["backgroundColor"] as! UIColor
         subtitle.setting.backgroundAlpha = Float(config?["backgroundAlpha"] as! Double)
         subtitle.setting.strokeColor = config?["strokeColor"] as! UIColor
+        subtitle.setting.strokeWidth =  CGFloat(config?["strokeWidth"] as! Double)
 
         if subtitleSettingCallBack != nil {
             subtitleSettingCallBack!(subtitle)
@@ -247,46 +259,37 @@ class BFSubtitleSettingView: UIView {
     }
 
     @objc func wordSizeSetting(sender: UIButton) {
-        
         if(sender.tag == 0){
-            if(subtitle.setting.subtitleSize > 40){
-                if(subtitle.setting.subtitleSize > 80){
-                    subtitle.setting.subtitleSize -= 20
-                }else{
-                    subtitle.setting.subtitleSize -= 10
-                }
+            if(wordSizeIndex == 0){
+                BFLog(2, message: "已经到边界最小")
+                return
             }
-            BFLog(message: "subtitle.setting.subtitleSize -  is\(subtitle.setting.subtitleSize )")
-            if(subtitle.setting.subtitleSize > 40){
-                lastSelectwordSizeBtn.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_h"), for: .normal)
-                
-                sender.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_h"), for: .normal)
-            }else{
-                sender.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_n"), for: .normal)
-            }
-            
+            wordSizeIndex -= 1
         }else  if(sender.tag == 1){
-            if(subtitle.setting.subtitleSize < 120){
-                if(subtitle.setting.subtitleSize >= 80){
-                    subtitle.setting.subtitleSize += 20
-                }else{
-                    subtitle.setting.subtitleSize += 10
-                }
-                
+            if(wordSizeIndex == 6){
+                BFLog(2, message: "已经到边界最大")
+                return
             }
-            BFLog(message: "subtitle.setting.subtitleSize +  is\(subtitle.setting.subtitleSize )")
-            
-            if(subtitle.setting.subtitleSize < 120){
-                sender.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_h"), for: .normal)
-                lastSelectwordSizeBtn.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_h"), for: .normal)
-            }else{
-                sender.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_n"), for: .normal)
-            }
-            
+            wordSizeIndex += 1
         }
- 
-        lastSelectwordSizeBtn = sender
+        BFLog(2, message: "wordSizeIndex is\(wordSizeIndex)")
+        if(wordSizeIndex == 0){
+            wordSizeBtnDa?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_h"), for: .normal)
 
+            wordSizeBtnXiao?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_n"), for: .normal)
+        }else if(wordSizeIndex == 6){
+            wordSizeBtnXiao?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_h"), for: .normal)
+
+            wordSizeBtnDa?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_n"), for: .normal)
+        }else{
+            
+            wordSizeBtnXiao?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting-_h"), for: .normal)
+
+            wordSizeBtnDa?.setImage(imageInRecordScreenKit(by:  "wordSizeSetting+_h"), for: .normal)
+        }
+        
+        let config = styleConfig[wordSizeIndex]
+        subtitle.setting.subtitleSize = config?["subtitleSize"] as! Int
         if subtitleSettingCallBack != nil {
             subtitleSettingCallBack!(subtitle)
         }