From: liangzhenying <867174124@qq.com> Date: Wed, 26 Nov 2025 09:34:13 +0000 (+0800) Subject: 中英互译虚线修改 X-Git-Tag: 1.0.2~52 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=3f2e2854ec1087820707365a692f93e6eab1d170;p=mirrors%2FShenYin.git 中英互译虚线修改 --- diff --git a/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift b/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift index 3d8863f..6d55316 100644 --- a/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift +++ b/ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift @@ -115,6 +115,7 @@ class Chinese2EnglishCell:BaseTableViewCell{ playIcon.startAnimating() } } + } diff --git a/ShenYin/ShenYin/UI/Home/Dialog/DialogTranslateCell.swift b/ShenYin/ShenYin/UI/Home/Dialog/DialogTranslateCell.swift index b6931dd..193a9bf 100644 --- a/ShenYin/ShenYin/UI/Home/Dialog/DialogTranslateCell.swift +++ b/ShenYin/ShenYin/UI/Home/Dialog/DialogTranslateCell.swift @@ -22,8 +22,7 @@ class DialogTranslateCellModel{ class DialogTranslateCell:BaseTableViewCell{ let bgView = UIView() -// let line = BrokenLineView() - let line = UIView() + private let line = BrokenLineView() let originalLabel = UILabel() let translationLabel = UILabel() let playIcon = UIImageView() @@ -57,7 +56,7 @@ class DialogTranslateCell:BaseTableViewCell{ v.textAlignment = .left } line.do { v in - v.backgroundColor = .hexString("#93C6EC") +// v.backgroundColor = .hexString("#93C6EC") } playIcon.do { v in v.image = UIImage(named: "play_animate_3") @@ -131,7 +130,6 @@ class DialogTranslateCell:BaseTableViewCell{ translationLabel.textColor = .hexString("#121212") } line.setNeedsLayout() - line.layoutIfNeeded() } } @objc func playAction(){ @@ -145,3 +143,4 @@ class DialogTranslateCell:BaseTableViewCell{ } } } + diff --git a/ShenYin/ShenYin/UI/common/BrokenLineView.swift b/ShenYin/ShenYin/UI/common/BrokenLineView.swift index e96c8f2..900401d 100644 --- a/ShenYin/ShenYin/UI/common/BrokenLineView.swift +++ b/ShenYin/ShenYin/UI/common/BrokenLineView.swift @@ -5,23 +5,55 @@ // Created by liangshi on 2025/8/26. // +//class BrokenLineView: UIView { +// override func draw(_ rect: CGRect) { +// super.draw(rect) +// let path = UIBezierPath() +// let lineWidth: CGFloat = 0.5 +// let dashLength: CGFloat = 5.0 +// let spaceLength: CGFloat = 3.0 +// let startPoint = CGPoint(x: 0, y: bounds.midY) +// let endPoint = CGPoint(x: bounds.width, y: bounds.midY) +// path.move(to: startPoint) +// path.addLine(to: endPoint) +// let shapeLayer = CAShapeLayer() +// shapeLayer.path = path.cgPath +// shapeLayer.strokeColor = UIColor.hexString("#93C6EC").cgColor +// shapeLayer.fillColor = UIColor.clear.cgColor +// shapeLayer.lineWidth = lineWidth +// shapeLayer.lineDashPattern = [NSNumber(value: dashLength), NSNumber(value: spaceLength)] +// layer.addSublayer(shapeLayer) +// } +//} class BrokenLineView: UIView { - override func draw(_ rect: CGRect) { - super.draw(rect) + private var shapeLayer: CAShapeLayer! + + override init(frame: CGRect) { + super.init(frame: frame) + setupShapeLayer() + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + setupShapeLayer() + } + + private func setupShapeLayer() { + shapeLayer = CAShapeLayer() + shapeLayer.strokeColor = UIColor.hexString("#93C6EC").cgColor + shapeLayer.fillColor = UIColor.clear.cgColor + shapeLayer.lineWidth = 0.5 + shapeLayer.lineDashPattern = [NSNumber(value: 5.0), NSNumber(value: 3.0)] + layer.addSublayer(shapeLayer) + } + + override func layoutSubviews() { + super.layoutSubviews() let path = UIBezierPath() - let lineWidth: CGFloat = 0.5 - let dashLength: CGFloat = 5.0 - let spaceLength: CGFloat = 3.0 let startPoint = CGPoint(x: 0, y: bounds.midY) let endPoint = CGPoint(x: bounds.width, y: bounds.midY) path.move(to: startPoint) path.addLine(to: endPoint) - let shapeLayer = CAShapeLayer() shapeLayer.path = path.cgPath - shapeLayer.strokeColor = UIColor.hexString("#93C6EC").cgColor - shapeLayer.fillColor = UIColor.clear.cgColor - shapeLayer.lineWidth = lineWidth - shapeLayer.lineDashPattern = [NSNumber(value: dashLength), NSNumber(value: spaceLength)] - layer.addSublayer(shapeLayer) } }