I am using CAShapeLayer to draw a circle , and wanted to check whether the layer is hit or not on zoomed scrollview with image view inside,,, the point is that hit test is not working for circular cashapelayer ,, help me in this regard
here is my code
let layer = CAShapeLayer()
let point = CGPoint(x: x, y: y)
let circlePath = UIBezierPath(arcCenter: .zero, radius: radius, startAngle: startAngle , endAngle: endAngle, clockwise: true)
layer.path = circlePath.cgPath
layer.position = point
layer.strokeColor = strokeColor
layer.fillColor = fillColor
layer.lineWidth = lineWidth
return layer
for layer in imageView.layer.sublayers!{
let point = layer.convert(touchValue, to: layer)
if (layer.hitTest(touchValue) != nil layer.contains(touchValue) layer.hitTest(point) != nil || layer.contains(point) ){
print(layer.name)
}
}
here is my code
let layer = CAShapeLayer()
let point = CGPoint(x: x, y: y)
let circlePath = UIBezierPath(arcCenter: .zero, radius: radius, startAngle: startAngle , endAngle: endAngle, clockwise: true)
layer.path = circlePath.cgPath
layer.position = point
layer.strokeColor = strokeColor
layer.fillColor = fillColor
layer.lineWidth = lineWidth
return layer
for layer in imageView.layer.sublayers!{
let point = layer.convert(touchValue, to: layer)
if (layer.hitTest(touchValue) != nil layer.contains(touchValue) layer.hitTest(point) != nil || layer.contains(point) ){
print(layer.name)
}
}