通过IOS中的2个视图绘制线条[关闭]

问题描述 投票:-7回答:1

如何从view1到view2画线像图像一样。

enter image description here

非常感谢!

ios swift line
1个回答
1
投票

您需要从一个视图到另一个视图绘制贝塞尔路径。

   let border = CAShapeLayer()
    border.strokeColor = UIColor.black.cgColor
    border.lineDashPattern = [6, 4]
    border.lineJoin = kCALineJoinRound
    border.lineCap = kCALineCapSquare
    border.frame = CGRect(x: 0, y: 0, width: 5, height: 10)
    border.strokeColor = Color.blue.cgColor
    border.fillColor = nil
    border.path = UIBezierPath(rect: CGRect(x: 0, y: 0, width: 5, height: 10).cgPath
    self.view.layer.addSublayer(border)
© www.soinside.com 2019 - 2024. All rights reserved.