To draw a vertically dashed line you could do the following:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let lineLayer = CAShapeLayer()
lineLayer.strokeColor = UIColor.gray.cgColor
lineLayer.lineWidth = 2
lineLayer.lineDashPattern = [4,4]
let path = CGMutablePath()
path.addLines(between: [CGPoint(x: 30, y: 50),
CGPoint(x: 30, y: 300)])
lineLayer.path = path
self.view.layer.addSublayer(lineLayer)
}
}
This gives this result:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.