中英互译虚线修改
authorliangzhenying <867174124@qq.com>
Wed, 26 Nov 2025 09:34:13 +0000 (17:34 +0800)
committerliangzhenying <867174124@qq.com>
Wed, 26 Nov 2025 09:34:13 +0000 (17:34 +0800)
ShenYin/ShenYin/UI/Home/Chinese2English/Chinese2EnglishCell.swift
ShenYin/ShenYin/UI/Home/Dialog/DialogTranslateCell.swift
ShenYin/ShenYin/UI/common/BrokenLineView.swift

index 3d8863f..6d55316 100644 (file)
@@ -115,6 +115,7 @@ class Chinese2EnglishCell:BaseTableViewCell{
             playIcon.startAnimating()
         }
     }
+    
 }
 
 
index b6931dd..193a9bf 100644 (file)
@@ -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{
         }
     }
 }
+
index e96c8f2..900401d 100644 (file)
@@ -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)
     }
 }