title: Moving a CAShapeLayer in Objective-C
body: <p><strong>THE CODE:</strong></p>
  
  <p>I have a circle created on top of UIImage. The code I have to use to create the Circle:</p>
  
  <pre><code>// Show the circle
  circleLayer = [CAShapeLayer layer];
  // Give the layer the same bounds as your image view
  [circleLayer setBounds:CGRectMake(0.0f, 0.0f, [colorWheel bounds].size.width,
                                    [colorWheel bounds].size.height)];
  // Position the circle anywhere you like, but this will center it
  // In the parent layer, which will be your image view's root layer
  [circleLayer setPosition:CGPointMake([colorWheel bounds].size.width/2.0f,
                                       [colorWheel bounds].size.height/2.0f)];
  // Create a circle path.
  UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:
                        CGRectMake(0.0f, 0.0f, 50.0f, 50.0f)];
  // Set the path on the layer
  [circleLayer setPath:[path CGPath]];
  // Set the stroke color
  [circleLayer setStrokeColor:[[UIColor redColor] CGColor]];
  [circleLayer setFillColor:[[UIColor blueColor] CGColor]];
  // Set the stroke line width
  [circleLayer setLineWidth:2.0f];
  
  // Add the sublayer to the image view's layer tree
  [[colorWheel layer] addSublayer:circleLayer];
  </code></pre>
  
  <p>I have a delegate function to pass the touch points:</p>
  
  <pre><code>- (void) touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
      UITouch* touch = [touches anyObject];
      [pickedColorDelegate getCurrentPosition:(UITouch *)touch];
  }
  </code></pre>
  
  <p>And the following code is used for updating the position of the circle:</p>
  
  <pre><code>-(void) getCurrentPosition:(UITouch *)touch {
      CGPoint touchPoint = [touch locationInView:self.view];
      [circleLayer setPosition:CGPointMake(touchPoint.x, touchPoint.y)];
  }
  </code></pre>
  
  <p><strong>THE PROBLEM:</strong></p>
  
  <p>CAShapeLayer does move, but It move's to a wrong position. See the screenshot for instance, I have marked the point where the circle is supposed to be.</p>
  
  <p><img src="https://i.stack.imgur.com/uRMG5.png" alt="enter image description here"></p>