This is just informationally. To use puzzleUnit.path, you have to flip the path vertically. Extension UIBezierPath:
func flipIt(vertically: Bool)
{
let rect = self.bounds
if vertically
{
self.apply(CGAffineTransform(translationX: 0, y: -rect.origin.y))
self.apply(CGAffineTransform(scaleX: 1, y: -1))
self.apply(CGAffineTransform(translationX: 0, y: rect.origin.y + rect.height))
}
else
{
//first, you need to move the view all the way to the left
//because otherwise, if you mirror it in its current position,
//the view will be thrown way off screen to the left
self.apply(CGAffineTransform(translationX: -rect.origin.x, y: 0))
//then you mirror it
self.apply(CGAffineTransform(scaleX: -1, y: 1))
//then, after its mirrored, move it back to its original position
self.apply(CGAffineTransform(translationX: rect.origin.x + rect.width, y: 0))
}
}
This is just informationally. To use
puzzleUnit.path
, you have to flip the path vertically.Extension UIBezierPath
: