|
@@ -9,7 +9,7 @@ import Foundation
|
|
|
import BFFramework
|
|
|
import BFCommonKit
|
|
|
|
|
|
-typealias SubtitleSettingCallBack = (_ subtitileSettingModel: BFSubtitileSettingModel?) -> Void
|
|
|
+typealias SubtitleSettingCallBack = (_ subtitileSettingModel: BFSubtitileSettingModel) -> Void
|
|
|
|
|
|
class BFSubtitleSettingView: UIView {
|
|
|
|
|
@@ -28,6 +28,9 @@ class BFSubtitleSettingView: UIView {
|
|
|
var subtitleSettingCallBack:SubtitleSettingCallBack?
|
|
|
|
|
|
var subtitleSetting:BFSubtitileSettingModel = BFSubtitileSettingModel.init()
|
|
|
+
|
|
|
+
|
|
|
+ var styleConfig:Dictionary<Int,Dictionary<String,Any>> = Dictionary.init()
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
@@ -44,21 +47,32 @@ class BFSubtitleSettingView: UIView {
|
|
|
make.width.equalTo(cScreenWidth)
|
|
|
make.height.equalTo(220)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ 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.black,"strokeColor":UIColor.black,"backgroundAlpha":0.6]
|
|
|
+ ]
|
|
|
|
|
|
|
|
|
|
|
|
for i in 0...6 {
|
|
|
let btn = UIButton(type: .custom)
|
|
|
btn.setImage(imageInRecordScreenKit(by: "wordStyle\(i + 1)"), for: .normal)
|
|
|
-
|
|
|
btn.setBackgroundImage(UIImage.init(color:.black), for: .normal)
|
|
|
btn.frame = CGRect.init(x: 18 + i * ( 40 + 10) , y: 22, width: 40, height: 40)
|
|
|
+ btn.tag = i
|
|
|
if(i == 0){
|
|
|
btn.isSelected = true
|
|
|
btn.layer.borderColor = UIColor.hexColor(hexadecimal: "#28BE67").cgColor
|
|
|
btn.layer.borderWidth = 1.5
|
|
|
lastSelectStyleBtn = btn
|
|
|
+
|
|
|
+ styleSetting(sender: lastSelectStyleBtn)
|
|
|
+
|
|
|
}
|
|
|
|
|
|
btn.addTarget(self, action: #selector(styleSetting(sender:)), for: .touchUpInside)
|
|
@@ -212,6 +226,18 @@ class BFSubtitleSettingView: UIView {
|
|
|
sender.layer.borderWidth = 1.5
|
|
|
|
|
|
subtitleSetting.subtitleStyle = sender.tag
|
|
|
+
|
|
|
+ let config = styleConfig[sender.tag]
|
|
|
+
|
|
|
+ subtitleSetting.fontColor = config?["fontColor"] as! UIColor
|
|
|
+ subtitleSetting.backgroundColor = config?["backgroundColor"] as! UIColor
|
|
|
+ subtitleSetting.backgroundAlpha = Float(config?["backgroundAlpha"] as! Double)
|
|
|
+ subtitleSetting.strokeColor = config?["strokeColor"] as! UIColor
|
|
|
+
|
|
|
+ if(subtitleSettingCallBack != nil){
|
|
|
+ subtitleSettingCallBack!(subtitleSetting)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
@objc func pointSetting(sender:UIButton){
|
|
|
|
|
@@ -226,7 +252,9 @@ class BFSubtitleSettingView: UIView {
|
|
|
|
|
|
subtitleSetting.subtitlePoint = sender.tag
|
|
|
|
|
|
-
|
|
|
+ if(subtitleSettingCallBack != nil){
|
|
|
+ subtitleSettingCallBack!(subtitleSetting)
|
|
|
+ }
|
|
|
}
|
|
|
@objc func wordSizeSetting(sender:UIButton){
|
|
|
|
|
@@ -238,38 +266,55 @@ class BFSubtitleSettingView: UIView {
|
|
|
|
|
|
sender.layer.borderColor = UIColor.hexColor(hexadecimal: "#28BE67").cgColor
|
|
|
sender.layer.borderWidth = 1.5
|
|
|
- if(sender.tag == 0){
|
|
|
- subtitleSetting.subtitleSize -= 10
|
|
|
- }else{
|
|
|
- subtitleSetting.subtitleSize += 10
|
|
|
- }
|
|
|
+
|
|
|
+ if(sender.tag == 0 && subtitleSetting.subtitleSize > 20){
|
|
|
+ subtitleSetting.subtitleSize -= 10
|
|
|
+ }else if(sender.tag == 1 && subtitleSetting.subtitleSize < 120){
|
|
|
+ subtitleSetting.subtitleSize += 10
|
|
|
+ }else{
|
|
|
+ BFLog(message: "设置字号超出范围!")
|
|
|
+ }
|
|
|
+ if(subtitleSettingCallBack != nil){
|
|
|
+ subtitleSettingCallBack!(subtitleSetting)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+
|
|
|
}
|
|
|
@objc func switchChange(uiswitch:UISwitch) {
|
|
|
print("字幕开关状态\(uiswitch.isOn )")
|
|
|
|
|
|
subtitleSetting.subtitleIsShow = !uiswitch.isOn
|
|
|
|
|
|
-
|
|
|
+ if(subtitleSettingCallBack != nil){
|
|
|
+ subtitleSettingCallBack!(subtitleSetting)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class BFSubtitileSettingModel: NSObject {
|
|
|
+public class BFSubtitileSettingModel: NSObject {
|
|
|
|
|
|
|
|
|
- var subtitleStyle:Int = 0
|
|
|
+ public var subtitleStyle:Int = 0
|
|
|
|
|
|
- var subtitlePoint:Int = 0
|
|
|
+ public var subtitlePoint:Int = 0
|
|
|
|
|
|
-
|
|
|
- var subtitleSize:Int = 60
|
|
|
+
|
|
|
+ public var subtitleSize:Int = 70
|
|
|
|
|
|
|
|
|
- var subtitleIsShow:Bool = true
|
|
|
+ public var subtitleIsShow:Bool = true
|
|
|
|
|
|
- var font: String = ""
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ public var fontColor: UIColor = .white
|
|
|
+
|
|
|
+ public var backgroundColor:UIColor = .clear
|
|
|
+
|
|
|
+ public var backgroundAlpha:Float = 1.0
|
|
|
+
|
|
|
+ public var strokeColor: UIColor = .white
|
|
|
+
|
|
|
+ public var strokeWidth: CGFloat = 6.0
|
|
|
+
|
|
|
|
|
|
}
|