I'm using UIBezierPath for draw ovalInRect on UIView its working properly but when I move UIView after I change ovalInRect then UIView take old position without change UIView position.
ellipsePath = UIBezierPath(ovalInRect: CGRectMake(0, 0, radiusValue , radiusValue))
shapeLayer.path = ellipsePath.CGPath
shapeLayer.fillColor = UIColor.clearColor().CGColor
shapeLayer.strokeColor = UIColor.blueColor().CGColor
shapeLayer.lineWidth = 1
shapeLayer.sublayers?.removeAll()
moveView.layer.addSublayer(shapeLayer)
Now I get ovalInRect on moveView now I move the moveView on screen using UIPanGestureRecognizer old place to any other place
func recognizePanGesture(sender: UIPanGestureRecognizer)
{
let translate = sender.translationInView(self.view)
sender.view!.center = CGPoint(x:sender.view!.center.x + translate.x,
y:sender.view!.center.y + translate.y)
sender.setTranslation(CGPointZero, inView: self.view)
}
Then after I update ovalInRect
ellipsePath.removeAllPoints()
let tempPath = CGPathCreateMutableCopy(ellipsePath.CGPath)
CGPathAddEllipseInRect(tempPath, nil, CGRectMake(0
,0, topA , rightB))
ellipsePath.CGPath = tempPath!
shapeLayer.path = ellipsePath.CGPath
shapeLayer.sublayers?.removeAll()
moveView.layer.addSublayer(shapeLayer)
moveView automatic move to old position (ovalInRect working properly).
I want don't change position when I update ovalInRect time.