小编Mas*_*shi的帖子

如何绘制方向箭头

我在许多方向和角度上都有线,我使用绘制了线UIBezierpath

我需要在这条线的一端画一个箭头。动态地根据给定的点。

编辑: 手绘,但应该给您更好的理解

编辑2:与杰克答案这是我的代码

let y2 = line.point2Y

let path = UIBezierPath()

  path.move(to: CGPoint(x: x1, y: y1))
  path.addLine(to: CGPoint(x: x2, y: y2))
path.addArrow(start: CGPoint(x: x1, y: y1), end: CGPoint(x: x2, y: y2), pointerLineLength: ...
path.close()

let shape = CAShapeLayer()
let shapeBorder = CAShapeLayer()
shapeBorder.strokeColor = UIColor.black.cgColor
shapeBorder.lineJoin = kCALineJoinRound
shapeBorder.lineCap = kCALineCapRound
shapeBorder.lineWidth = 10
shapeBorder.addSublayer(shape)

shape.path = path.cgPath
shapeBorder.path = shape.path
shape.lineJoin = kCALineJoinRound
shape.lineCap = kCALineCapRound
shape.lineWidth = shapeBorder.lineWidth-5.0
shape.strokeColor = color
Run Code Online (Sandbox Code Playgroud)

但是有阴影 在此处输入图片说明

ios uibezierpath swift3

-1
推荐指数
1
解决办法
2644
查看次数

标签 统计

ios ×1

swift3 ×1

uibezierpath ×1