我有一个可以拉伸和旋转到任何角度的直线 UIBezierpath:
这是我想要实现的目标:
当我触摸黑色箭头点时,它应该说isContain = true并返回一个CGPoint接近touchPoint并且必须在path(蓝色箭头)中间的。
例如:黑色箭头点 is (x:251,y:302)but it should return (x:250, y:300),在中间path
这是我尝试过的,但它只适用于水平线
func hasForHorizontalLine(pt point: CGPoint) -> Bool{
let bezierRect = bounds
let origin = bezierRect.origin
let size = bezierRect.size
if origin.x <= point.x , origin.x + size.width >= point.x, origin.y - lineWidth * 0.5 <= point.y , origin.y + lineWidth * 0.5 >= point.y{
return true
}
else{
return false
}
}
