我需要画一条从0,0开始、长度和角度(从顶部视角)已知的直线。目前可以通过给出起点和终点来创建一条线,但是我需要使用角度和长度来代替终点,请帮忙。
以下是代码:
let path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 0))
path.addLine(to: CGPoint(x: 0+10, y: 0+10))
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.strokeColor = UIColor.blue.cgColor
shapeLayer.lineWidth = 3.0