|
@@ -8,12 +8,17 @@
|
|
|
import Foundation
|
|
|
import BFUIKit
|
|
|
import BFFramework
|
|
|
+
|
|
|
+typealias EditSubtitleDone = (_ text: String) -> Void
|
|
|
+
|
|
|
class BFSubtitleEditView: UIView {
|
|
|
+ var editSubtitleDone:EditSubtitleDone?
|
|
|
|
|
|
+ var settingModel:BFSubtitileSettingModel = BFSubtitileSettingModel.init()
|
|
|
/// 输入框
|
|
|
lazy var textView: BFTextView = {
|
|
|
let textView = BFTextView()
|
|
|
- textView.maxTextLength = 300
|
|
|
+ textView.maxTextLength = 30
|
|
|
textView.maxTextLengthRemind = ""
|
|
|
textView.backgroundColor = UIColor.clear
|
|
|
textView.textColor = UIColor.hexColor(hexadecimal: "#FFFFFF")
|
|
@@ -39,8 +44,8 @@ class BFSubtitleEditView: UIView {
|
|
|
}
|
|
|
override init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
|
- backgroundColor = .black
|
|
|
- alpha = 0.7
|
|
|
+ backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.7)
|
|
|
+// alpha = 0.7
|
|
|
addSubview(textView)
|
|
|
textView.snp.makeConstraints { make in
|
|
|
make.left.equalTo(37)
|
|
@@ -55,12 +60,13 @@ class BFSubtitleEditView: UIView {
|
|
|
doneBtn.setTitle("完成", for: .normal)
|
|
|
doneBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
|
|
|
doneBtn.addTarget(self, action: #selector(doneAction), for: .touchUpInside)
|
|
|
+ doneBtn.addCorner(corner:4)
|
|
|
addSubview(doneBtn)
|
|
|
doneBtn.snp.makeConstraints { make in
|
|
|
make.right.equalTo(-12)
|
|
|
make.width.equalTo(60)
|
|
|
make.height.equalTo(36)
|
|
|
- make.top.equalToSuperview().offset(45)
|
|
|
+ make.top.equalToSuperview().offset(48)
|
|
|
}
|
|
|
|
|
|
let cancelBtn = UIButton()
|
|
@@ -76,22 +82,33 @@ class BFSubtitleEditView: UIView {
|
|
|
make.height.equalTo(36)
|
|
|
make.top.equalToSuperview().offset(45)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@objc func cancelAction(){
|
|
|
self.isHidden = true
|
|
|
+ textView.resignFirstResponder()
|
|
|
}
|
|
|
|
|
|
@objc func doneAction(){
|
|
|
self.isHidden = true
|
|
|
+ textView.resignFirstResponder()
|
|
|
+ if(editSubtitleDone != nil){
|
|
|
+ BFLog(message: "最后修改的文字为:\(String(describing: textView.text))")
|
|
|
+ editSubtitleDone!(textView.text)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ func setNewText(text:String) {
|
|
|
+
|
|
|
+ textView.text = text.substring(to: 30)
|
|
|
+// 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])
|
|
|
+// textView.attributedText = attributedText
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -112,9 +129,7 @@ extension BFSubtitleEditView: UITextViewDelegate{
|
|
|
return false
|
|
|
}
|
|
|
BFLog(message: "inputText \(String(describing: textView.text))")
|
|
|
-
|
|
|
- let attributedText = NSMutableAttributedString(string: textView.text,attributes: [.font: UIFont.systemFont(ofSize: 34),.strokeWidth:-3,.strokeColor:UIColor.orange])
|
|
|
- textView.attributedText = attributedText
|
|
|
+
|
|
|
return true
|
|
|
}
|
|
|
}
|