Преглед изворни кода

定义字幕最大限制数

jsonwang пре 3 година
родитељ
комит
e625b9863d

+ 2 - 2
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -1298,8 +1298,8 @@ extension BFRecordScreenController: PQSpeechTranscriberUtilDelegate {
 
             newSubtitle.timelineOut = Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0 + (self.recorderManager.voiceModel?.startTime ?? 0.0)
             var showText = ((payload?["result"]) as? String) ?? ""
-            if showText.count > 30 {
-                showText = showText.substring(to: 30)
+            if showText.count > subtitleMaxlength {
+                showText = showText.substring(to: subtitleMaxlength)
                 showText += "..."
             }
             newSubtitle.text = showText

+ 6 - 2
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleEditView.swift

@@ -12,6 +12,10 @@ import Foundation
 
 typealias EditSubtitleDone = (_ text: String,_ index:Int) -> Void
 
+
+//字幕最大数限制
+public let subtitleMaxlength:Int = 30
+
 class BFSubtitleEditView: UIView {
     
     var showSubtitleIndex = 0
@@ -21,7 +25,7 @@ class BFSubtitleEditView: UIView {
     /// 输入框
     lazy var textView: BFTextView = {
         let textView = BFTextView()
-        textView.maxTextLength = 30
+        textView.maxTextLength = subtitleMaxlength
         textView.maxTextLengthRemind = ""
         textView.backgroundColor = UIColor.clear
         textView.textColor = UIColor.hexColor(hexadecimal: "#FFFFFF")
@@ -99,7 +103,7 @@ class BFSubtitleEditView: UIView {
 
     func setNewText(text: String,index:Int) {
         showSubtitleIndex = index
-        textView.text = text.substring(to: 30)
+        textView.text = text.substring(to: subtitleMaxlength)
 //        BFLog(message: "传值\(textView.text)")
 //
 //        let attributedText = NSMutableAttributedString(string: textView.text,attributes: [.font: UIFont.systemFont(ofSize: CGFloat(settingModel.subtitleSize)  * 375 / 1080),.strokeWidth:-6,.strokeColor: settingModel.strokeColor,.foregroundColor:settingModel.fontColor])