- 通过Quartz2D画虚线
func drawDashLine(view: UIView) {
let dashShapeLayer = CAShapeLayer()
dashShapeLayer.strokeColor = UIColor.red.cgColor
dashShapeLayer.lineWidth = 2
let shapePath = CGMutablePath()
dashShapeLayer.lineDashPattern = [10,5]
shapePath.move(to: .init(x: 20, y: 230))
shapePath.addLine(to: .init(x: 335, y: 230))
dashShapeLayer.path = shapePath
view.layer.addSublayer(dashShapeLayer)
}