-
Notifications
You must be signed in to change notification settings - Fork 247
Open
Labels
Description
It might be useful if SVGLayer had a readonly property to access the path with the rendering transformation applied.
Original title: path.contains(point) correctly works only when SVGImageView contentMode is bottomeLeft
I'm building a fill-on-tap demo on top of the Demo-iOS project.
I added a UITapGestureRecognizer to the SVGImageView. I'm aiming to fill the subpath under the tapped point with a color. My code so far:
@IBAction func didTapImageView(_ sender: UITapGestureRecognizer) {
let svgView = sender.view as! SVGImageView
let point = sender.location(in: svgView)
svgView.paths = svgView.paths.map { path in
var p: SVGBezierPath = path
if path.contains(point) {
p = path.settingSVGAttributes(["fill": colors[colorIndex].cgColor])
colorIndex = (colorIndex + 1) % colors.count
}
print(point)
print(p)
return p
}
}
This correctly works only if the contentMode of the SVGImageView is bottomLeft. Other modes acknowledges the tapped point while it's actually rendered somewhere else. Any ideas what may be wrong?