--- /dev/null
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "filename" : "record_normal@2x.png",
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "filename" : "record_normal@3x.png",
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
--- /dev/null
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "filename" : "Frame 1986@2x.png",
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "filename" : "Frame 1986@3x.png",
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
--- /dev/null
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "filename" : "Frame@2x.png",
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "filename" : "Frame@3x.png",
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
--- /dev/null
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "filename" : "Ellipse_52@2x.png",
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "filename" : "Ellipse_52@3x.png",
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
--- /dev/null
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "filename" : "Group 1255@2x.png",
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "filename" : "Group 1255@3x.png",
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
navBar.title = "通话录音"
toolBar.delegate = self
toolBar.hasRightItem = false
+ navBar.backgroundColor = .white
+ toolBar.delegate = self
+ view.backgroundColor = .white
textView.do { v in
- v.backgroundColor = .hexString("#F7F7F7")
+ v.backgroundColor = .white
v.isEditable = false
v.font = .regular(14)
v.text = ""
}
class ChatRecordBar:BaseView{
- private var recordBtn = UIButton(type: .custom)
+ private var label = UILabel()
+ private var animationBg = UIView()
+ private var animationView = UIImageView()
weak var delegate:ChatRecordBarDelegate?
var isRecord:Bool = false{
didSet{
- recordBtn.isSelected = isRecord
+ if isRecord {
+ animationBg.backgroundColor = .hexString("#0092E1")
+ animationView.isHidden = false
+ label.text = ""
+ }
+ else{
+ animationBg.backgroundColor = .white
+ animationView.isHidden = true
+ animationView.isHidden = true
+ label.text = "按住说话"
+ }
}
}
override func setupViews() {
- recordBtn.backgroundColor = .blue
- recordBtn.setTitle("开始录音", for: .normal)
- recordBtn.setTitle("停止录音", for: .selected)
- recordBtn.addTarget(self, action: #selector(recordAction), for: .touchUpInside)
- addSubview(recordBtn)
+ addSubview(animationBg)
+ animationBg.addSubviews([label,animationView])
+
+ backgroundColor = .clear
+ label.do { v in
+ v.textColor = .hexString("#121212")
+ v.font = .bold(16)
+ v.textAlignment = .center
+ }
+
+ animationBg.do { v in
+ v.yc.setCornerRadius(16)
+ animationBg.backgroundColor = .white
+ }
+
+ animationView.kf.setImage(with: Bundle.main.url(forResource: "dialog_record", withExtension: "gif")!)
+ self.isRecord = false
+ let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(_:)))
+ self.addGestureRecognizer(longPressGesture)
+
}
override func setupLayout() {
- recordBtn.snp.makeConstraints { make in
- make.width.centerX.bottom.equalToSuperview()
- make.height.equalToSuperview()
+ animationBg.snp.makeConstraints { make in
+ make.left.right.equalToSuperview().inset(18)
+ make.top.height.equalToSuperview()
+ }
+ animationView.snp.makeConstraints { make in
+ make.width.equalTo(218)
+ make.height.equalTo(24)
+ make.center.equalToSuperview()
+ }
+ label.snp.makeConstraints { make in
+ make.edges.equalToSuperview()
}
}
- @objc func recordAction(){
- recordBtn.isSelected = !recordBtn.isSelected
- if recordBtn.isSelected{
+ @objc func handleLongPress(_ gesture: UILongPressGestureRecognizer) {
+ switch gesture.state {
+ case.began:
+ print("started")
+ self.isRecord = true
delegate?.recordBarStart(self)
- }
- else{
+ case.ended:
+ print("ended")
+ self.isRecord = false
delegate?.recordBarStop(self)
+ default:
+ break
}
}
+
}
toolBar.snp.makeConstraints { make in
make.width.centerX.equalToSuperview()
make.height.equalTo(52)
- make.bottom.equalToSuperview().inset(20)
+ make.bottom.equalToSuperview().inset(30)
}
tableView.snp.makeConstraints { make in
make.top.equalToSuperview().inset(80)
// } catch {
// print(error)
// }
+
+ if TipsCache.needShow(type: .chinese2english) {
+ RecordTipsView(type: .chinese2english).show()
+ }
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
print(error)
}
PcmSound.sharedInstance().setup(16000, withchannels: 1)
+
+ if TipsCache.needShow(type: .dialog) {
+ RecordTipsView(type: .dialog).show()
+ }
}
override func navRightViewTapped() {
let tip = RecordTipsView(type: .tongchuan)
var hasRightItem:Bool = true
override func setupViews() {
- backgroundColor = .hexString("#F7F7F7")
+ backgroundColor = .white
addSubviews([leftItem,rightItem,recordBtn])
recordBtn.do { v in
override func setupViews() {
navBar.title = "现场录音"
+ navBar.backgroundColor = .white
toolBar.delegate = self
-
+ view.backgroundColor = .white
textView.do { v in
v.isEditable = false
v.font = .regular(14)
v.text = ""
- v.backgroundColor = .hexString("#F7F7F7")
+ v.backgroundColor = .white
v.textColor = .hexString("#121212")
v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18)
}
import UIKit
-//import DSWaveformImage
+import Kingfisher
class RhythView: BaseView {
let lable = UILabel()
- let wave = UIView()
+ let startWave = UIImageView()
+ let stopWave = UIImageView()
+ let wave = UIImageView()
var timer:Timer?
var num = 0
-// let wave = WaveformLiveView(frame: CGRect(x: 0, y: 0, width: kScreenWid, height: 50))
override func setupViews() {
- addSubviews([lable,wave])
+ addSubviews([startWave,stopWave,lable])
lable.do { v in
v.textColor = .hexString("#121212")
v.font = .bold(32)
v.textAlignment = .center
v.text = "00:00:00"
}
+
+ stopWave.image = UIImage(named: "audio_record_normal")
+ startWave.kf.setImage(with: Bundle.main.url(forResource: "record_start", withExtension: "gif")!)
+ startWave.isHidden = true
+// startWave.backgroundColor = .green
// backgroundColor = .red
- wave.backgroundColor = .lightGray
}
override func setupLayout() {
lable.snp.makeConstraints { make in
- make.top.equalToSuperview().inset(10)
+ make.top.equalToSuperview().inset(0)
make.centerX.equalToSuperview()
}
- wave.snp.makeConstraints { make in
+ stopWave.snp.makeConstraints { make in
make.top.equalToSuperview().inset(40)
make.left.right.equalToSuperview()
make.height.equalTo(58)
make.bottom.equalToSuperview()
}
+ startWave.snp.makeConstraints { make in
+ make.edges.equalTo(stopWave)
+ }
}
@objc func timerAction(){
num += 1
lable.text = YLToos.formatSeconds(num)
}
func startTimer(){
+ startWave.isHidden = false
+ stopWave.isHidden = true
if let timer = timer,timer.isValid{
timer.invalidate()
}
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
}
func stopTimer(){
+ startWave.isHidden = true
+ stopWave.isHidden = false
timer?.invalidate()
}
}
--- /dev/null
+//
+// RecordDetaiContent.swift
+// ShenYin
+//
+// Created by liangshi on 2025/9/26.
+//
+
+class RecordDetaiContent: BaseView {
+ let titleLabel = UILabel()
+ let btn = UIButton(type: .custom)
+ let textView = UITextView()
+ var title:String!{
+ didSet{
+ titleLabel.text = title
+ }
+ }
+ var content:String!{
+ didSet{
+ textView.text = content
+ }
+ }
+
+ override func setupViews() {
+ addSubviews([titleLabel,textView,btn])
+
+ titleLabel.do { v in
+ v.textColor = .rgb(0x0092E1)
+ v.font = .regular(16)
+ }
+ btn.do { v in
+ v.setImage(UIImage(named: "record_detail_copy"), for: .normal)
+ v.addTarget(self, action: #selector(copyAction), for: .touchUpInside)
+ }
+ textView.do { v in
+ v.font = .regular(14)
+ v.text = ""
+ v.textColor = .hexString("#121212")
+ v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18)
+ v.backgroundColor = .clear
+ v.isEditable = false
+ }
+ backgroundColor = .color(.bgColor)
+ }
+
+ override func setupLayout() {
+ titleLabel.snp.makeConstraints { make in
+ make.top.equalToSuperview().inset(15)
+ make.left.equalToSuperview().inset(18)
+ }
+ btn.snp.makeConstraints { make in
+ make.size.equalTo(26)
+ make.right.equalToSuperview().inset(18)
+ make.centerY.equalTo(titleLabel)
+ }
+ textView.snp.makeConstraints { make in
+ make.top.equalToSuperview().inset(35)
+ make.left.right.equalToSuperview()
+ make.bottom.equalToSuperview().inset(10)
+ }
+ }
+ @objc func copyAction(){
+ UIPasteboard.general.string = textView.text
+// YLprogressHUD.showAutoHiden("已拷贝")
+ }
+}
protocol RecordDetailTopBarDelegate {
func recordDetailBarTranstlateAction(_ bar:RecordDetailTopBar)
func recordDetailTopBarOgrinAction(_ bar:RecordDetailTopBar)
+ func recordDetailTopBarSummaryAction(_ bar:RecordDetailTopBar)
}
class RecordDetailTopBar: BaseView {
let tranlateItem = LanguageItem()
let originItem = LanguageItem()
-
+ let summaryItem = LanguageItem()
var delegate:RecordDetailTopBarDelegate?
override func setupViews() {
backgroundColor = .clear
- addSubviews([tranlateItem,originItem])
+ addSubviews([tranlateItem,originItem,summaryItem])
+ originItem.do {v in
+ v.yc.addTap(target: self, action: #selector(originAction))
+ v.label.text = "原文"
+ v.isSelected = true
+ }
tranlateItem.do {v in
v.yc.addTap(target: self, action: #selector(tralateAction))
v.label.text = "译文"
v.isSelected = false
}
- originItem.do {v in
- v.yc.addTap(target: self, action: #selector(originAction))
- v.label.text = "原文"
- v.isSelected = true
+ summaryItem.do {v in
+ v.yc.addTap(target: self, action: #selector(summaryAction))
+ v.label.text = "摘要"
+ v.isSelected = false
}
}
make.width.equalTo(100)
make.top.equalToSuperview()
make.height.equalTo(36)
- make.right.equalToSuperview().inset(kScreenWid/2 + 15)
+ make.left.equalToSuperview().inset(18)
}
tranlateItem.snp.makeConstraints { make in
make.width.equalTo(100)
make.top.equalToSuperview()
make.height.equalTo(36)
- make.left.equalToSuperview().offset(kScreenWid/2 + 15)
+ make.centerX.equalToSuperview()
+ }
+ summaryItem.snp.makeConstraints { make in
+ make.width.equalTo(100)
+ make.top.equalToSuperview()
+ make.height.equalTo(36)
+ make.right.equalToSuperview().inset(18)
}
}
@objc func tralateAction(){
originItem.isSelected = !originItem.isSelected
delegate?.recordDetailTopBarOgrinAction(self)
}
-
+ @objc func summaryAction(){
+ summaryItem.isSelected = !summaryItem.isSelected
+ delegate?.recordDetailTopBarSummaryAction(self)
+ }
+
class LanguageItem: BaseView {
let label = UILabel()
let timeLabel = UILabel()
let topBar = RecordDetailTopBar()
let toolBar = RecordDetailBar()
- let textView = UITextView()
- var messageList : [(String,UInt)] = []
- var recordFilePath : String?
-
+ let originView = RecordDetaiContent()
+ let translateView = RecordDetaiContent()
+ let summaryView = RecordDetaiContent()
override func viewDidLoad() {
super.viewDidLoad()
}
override func setupViews() {
navBar.title = "现场录音"
- navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal)
+ navBar.rightView.setImage(UIImage(named: "upload"), for: .normal)
+
toolBar.delegate = self
- topBar.delegate = self
+ topBar.do { v in
+ v.delegate = self
+ }
timeLabel.do { (v) in
v.font = .regular(14)
v.textColor = .hexString("#666666")
v.text = Date().format(.full3)
}
- textView.do { v in
- v.font = .regular(14)
- v.text = ""
- v.textColor = .hexString("#121212")
- v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18)
+ originView.do { v in
+ v.title = "原文"
+// v.content = "好优美的一篇文章,山花落尽,我心犹青|||记得春日时分,山花绽放得那样热烈,鲜红的、明黄的、洁白的,仿佛将整片山野染成了一幅画。那时的心也如山花般明亮,轻快地跳跃在生活的每一个角落。"
}
- view.addSubviews([timeLabel,topBar,textView,toolBar])
+ translateView.do { v in
+ v.title = "译文"
+// v.content = "What a beautiful article, the mountain flowers have all fallen, yet my heart remains green ||| Remembering the springtime, the mountain flowers bloomed so vividly, bright red, bright yellow, and pure white, as if they had painted the entire mountain wilderness into a picture. At that time, my heart was as bright as the mountain flowers, joyfully jumping around in every corner of life. "
+ }
+ summaryView.do { v in
+ v.title = "摘要"
+// v.content = "这是摘要"
+ }
+ view.addSubviews([timeLabel,topBar,originView,translateView,summaryView,toolBar])
}
override func setupLayout() {
toolBar.snp.makeConstraints { make in
make.width.centerX.equalToSuperview()
make.height.equalTo(95)
- make.bottom.equalToSuperview().inset(20)
- }
- textView.snp.makeConstraints { make in
- make.top.equalTo(topBar.snp.bottom)
- make.left.right.equalToSuperview()
- make.bottom.equalTo(toolBar.snp.top)
+ make.bottom.equalToSuperview()
}
+ updateLayout()
}
override func setupData() {
- PcmSound.sharedInstance().delegate = self;
- PcmSound.sharedInstance().setup(16000, withchannels: 1)
- let options: AVAudioSession.CategoryOptions = [.allowBluetooth]
- do {
- try AVAudioSession.sharedInstance().setCategory(.playback, options: [options])
- try AVAudioSession.sharedInstance().setActive(true)
- } catch {
- Logger.debug(error)
- }
+
}
override func navRightViewTapped() {
}
- func scrollToBottom(){
- let range = NSMakeRange(textView.text.count - 1, 1)
- textView.scrollRangeToVisible(range)
+
+ func updateLayout(){
+ var h = 0.0
+
+ if topBar.originItem.isSelected && topBar.tranlateItem.isSelected && topBar.summaryItem.isSelected{
+ originView.isHidden = false
+ translateView.isHidden = false
+ summaryView.isHidden = false
+ h = (kScreenHei - kNavBtm - 36 - 36 - 95)/3
+ originView.snp.remakeConstraints { make in
+ make.top.equalTo(topBar.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ translateView.snp.remakeConstraints { make in
+ make.top.equalTo(originView.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ summaryView.snp.remakeConstraints { make in
+ make.top.equalTo(translateView.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ }
+ else if topBar.originItem.isSelected && topBar.tranlateItem.isSelected{
+ originView.isHidden = false
+ translateView.isHidden = false
+ summaryView.isHidden = true
+ h = (kScreenHei - kNavBtm - 36 - 36 - 95)/2
+ originView.snp.remakeConstraints { make in
+ make.top.equalTo(topBar.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ translateView.snp.remakeConstraints { make in
+ make.top.equalTo(originView.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ }
+ else if topBar.originItem.isSelected && topBar.summaryItem.isSelected{
+ originView.isHidden = false
+ translateView.isHidden = true
+ summaryView.isHidden = false
+ h = (kScreenHei - kNavBtm - 36 - 36 - 95)/2
+ originView.snp.remakeConstraints { make in
+ make.top.equalTo(topBar.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ summaryView.snp.remakeConstraints { make in
+ make.top.equalTo(originView.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ }
+ else if topBar.tranlateItem.isSelected && topBar.summaryItem.isSelected{
+ originView.isHidden = true
+ translateView.isHidden = false
+ summaryView.isHidden = false
+ h = (kScreenHei - kNavBtm - 36 - 36 - 95)/2
+ translateView.snp.remakeConstraints { make in
+ make.top.equalTo(topBar.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ summaryView.snp.remakeConstraints { make in
+ make.top.equalTo(translateView.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ }
+ else if topBar.originItem.isSelected {
+ originView.isHidden = false
+ translateView.isHidden = true
+ summaryView.isHidden = true
+ h = (kScreenHei - kNavBtm - 36 - 36 - 95)
+ originView.snp.remakeConstraints { make in
+ make.top.equalTo(topBar.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ }
+ else if topBar.tranlateItem.isSelected {
+ originView.isHidden = true
+ translateView.isHidden = false
+ summaryView.isHidden = true
+ h = (kScreenHei - kNavBtm - 36 - 36 - 95)
+ translateView.snp.remakeConstraints { make in
+ make.top.equalTo(topBar.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ }
+ else if topBar.summaryItem.isSelected {
+ originView.isHidden = false
+ translateView.isHidden = true
+ summaryView.isHidden = false
+ h = (kScreenHei - kNavBtm - 36 - 36 - 95)
+ summaryView.snp.remakeConstraints { make in
+ make.top.equalTo(topBar.snp.bottom)
+ make.left.right.equalToSuperview()
+ make.height.equalTo(h)
+ }
+ }else{
+ originView.isHidden = true
+ translateView.isHidden = true
+ summaryView.isHidden = true
+ }
+
+
}
}
extension RecordDetailVC:RecordDetailTopBarDelegate{
+ func recordDetailTopBarSummaryAction(_ bar: RecordDetailTopBar) {
+ updateLayout()
+ }
+
func recordDetailBarTranstlateAction(_ bar: RecordDetailTopBar) {
-
+ updateLayout()
}
func recordDetailTopBarOgrinAction(_ bar: RecordDetailTopBar) {
-
+ updateLayout()
}
}
extension RecordDetailVC:RecordDetailBarDelegate{
}
}
-
-extension RecordDetailVC : PcmSoundDelegate {
-
- func remaining(_ frames: UInt) {
- Logger.debug("[frame:\(frames)]");
- }
-}
Logger.debug(error)
}
PcmSound.sharedInstance().setup(16000, withchannels: 1)
+
+ if TipsCache.needShow(type: .tongchuan) {
+ RecordTipsView(type: .tongchuan).show()
+ }
}
override func navRightViewTapped() {
let tip = RecordTipsView(type: .tongchuan)
extension App{
var deviceValid:Bool{
return BleManager.shared.isConnetd
+// return !BleManager.shared.isConnetd
}
}
App.shared.window = window
window?.rootViewController = BaseTC()
-// window?.rootViewController = UINavigationController(rootViewController: DialogTranslateVC())
+// window?.rootViewController = UINavigationController(rootViewController: ChatVC())
AppLaunch.start()
}
--- /dev/null
+//
+// c.swift
+// ShenYin
+//
+// Created by liangshi on 2025/9/11.
+//
+import CoreBluetooth
+
+class CacheManager{
+ static let shared = CacheManager()
+ var currentDevice:DeviceModel?
+
+ func saveDevice(_ device: DeviceModel) {
+ self.currentDevice = device
+ DeviceCache.shared.saveDevice(device)
+ }
+}
+
//
-// c.swift
+// DeviceCache.swift
// ShenYin
//
-// Created by liangshi on 2025/9/11.
+// Created by liangshi on 2025/9/26.
//
-import CoreBluetooth
-
-class CacheManager{
- static let shared = CacheManager()
- var currentDevice:DeviceModel?
-
- func saveDevice(_ device: DeviceModel) {
- self.currentDevice = device
- DeviceCache.shared.saveDevice(device)
- }
-}
class DeviceModel: NSObject, NSCoding {
var name = ""
--- /dev/null
+//
+// TipsCache.swift
+// ShenYin
+//
+// Created by liangshi on 2025/9/26.
+//
+
+
+
+
+class TipsCache{
+ static func needShow(type:RecordTipsType,show:Bool){
+ UserDefaults.standard.set(show, forKey: type.title)
+ }
+ static func needShow(type:RecordTipsType)->Bool{
+ if let value = UserDefaults.standard.value(forKey: type.title){
+ return value as? Bool ?? false
+ }
+ return true
+ }
+}
}
func startAnimating(finished:(()->Void)? = nil){
loading = true
- activeView.backgroundColor = .hexString("#F7F7F7")
+ activeView.backgroundColor = .white
activeView.startAnimating()
DispatchQueue.main.asyncAfter(deadline:.now() + 2) {
self.stopAnimating()
let desLabel1 = UILabel()
let desLabel2 = UILabel()
let actionbtn = UIButton(type: .custom)
+ let agreeView = AgreeView()
var didSelected: ((Int,String)->Void)?
var tipsType:RecordTipsType = .dialog
init(type:RecordTipsType) {
tipsType = type
- let h = 595.0
+ let h = 620.0
super.init(contentHeight:h)
}
override func setupSubView() {
super.setupSubView()
- contentView.addSubviews([titleLabel,btn,tipsIcon,desLabel1,desLabel2,actionbtn])
+ contentView.addSubviews([titleLabel,btn,tipsIcon,desLabel1,desLabel2,actionbtn,agreeView])
}
override func setupLayout() {
super.setupLayout()
m.left.right.equalToSuperview().inset(30)
}
actionbtn.snp.makeConstraints { (m) in
- m.bottom.equalToSuperview().inset(30)
+ m.bottom.equalToSuperview().inset(60)
m.left.right.equalToSuperview().inset(52)
m.height.equalTo(46)
}
-
+ agreeView.snp.makeConstraints { (m) in
+ m.bottom.equalToSuperview().inset(20)
+ m.centerX.equalToSuperview()
+ m.height.equalTo(30)
+ }
}
override func setupStyle() {
v.setTitleColor(.white, for: .normal)
v.addTarget(self, action: #selector(btnAction), for: .touchUpInside)
}
+ agreeView.do { v in
+ v.agreeBtn.isSelected = false
+ v.agreeBtn.addTarget(self, action: #selector(agreeBtnAction), for: .touchUpInside)
+ }
}
@objc func closeAction(){
hide()
@objc func btnAction(){
hide()
}
+ @objc func agreeBtnAction(){
+ agreeView.agreeBtn.isSelected = !agreeView.agreeBtn.isSelected
+ TipsCache.needShow(type: tipsType, show: !agreeView.agreeBtn.isSelected)
+ }
+ class AgreeView: BaseView {
+ let agreeBtn = UIButton()
+ let agreeTitle = UILabel()
+ override func setupViews() {
+ agreeBtn.do { (v) in
+ v.isSelected = true
+ v.contentMode = .center
+ v.setImage(UIImage(named: "tip_normal"), for: .normal)
+ v.setImage(UIImage(named: "tip_selected"), for: .selected)
+ }
+ agreeTitle.do { (v) in
+ v.textColor = .hexString("##999999")
+ v.font = .regular(12)
+ v.textAlignment = .left
+ v.text = "下次不再提示"
+ }
+// backgroundColor = .red
+ addSubviews([agreeBtn,agreeTitle])
+ }
+ override func setupLayout() {
+ agreeBtn.snp.makeConstraints { (m) in
+ m.left.top.equalToSuperview()
+ m.height.equalTo(30)
+ m.width.equalTo(30)
+ }
+ agreeTitle.snp.makeConstraints { (m) in
+ m.left.equalTo(agreeBtn.snp.right)
+ m.height.equalToSuperview()
+ m.centerY.equalTo(agreeBtn)
+ m.right.equalToSuperview()
+ }
+ }
+ }
+
}