title: Setting anchor point for UIView layer
body: <p>I have a UIView subclass that I want to be able to move around within it's superview. When the user touches the UIView somewhere outside <code>self.center</code> but within <code>self.bounds</code> it "jumps" because I add the new location to <code>self.center</code> to achieve the actual move. To avoid this behavior I'm trying to set an anchor point that lets the user grab and drag the view anywhere within it's bounds.</p>
  
  <p>My problem is that when I calculate the new anchor point (as shown in the code below) nothing happens, the view doesn't change position at all. On the other hand, if I set the anchor point to a precalculated point I can move the view (but then of course it "jumps" to the precalculated point). How come this doesn't work as expected?</p>
  
  <p>Thanks.</p>
  
  <pre><code>- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
  {
      // Only support single touches, anyObject retrieves only one touch
      UITouch *touch = [touches anyObject];
      CGPoint locationInView = [touch locationInView:self];
  
      // New location is somewhere within the superview
      CGPoint locationInSuperview = [touch locationInView:self.superview];
  
      // Set an anchorpoint that acts as starting point for the move
      // Doesn't work!
      self.layer.anchorPoint = CGPointMake(locationInView.x / self.bounds.size.width, locationInView.y / self.bounds.size.height);
      // Does work!
      self.layer.anchorPoint = CGPointMake(0.01, 0.0181818);
  
      // Move to new location
      self.center = locationInSuperview;
  }
  </code></pre>