views:

469

answers:

1

I try to set the anchorPoint property, in order to rotate a view by a well defined axis. But:

myView.layer.anchorPoint = CGPointMake(myView.layer.anchorPoint.x - 1.0, myView.layer.anchorPoint.y);

Wenn I shift it by -1.0, it will not just move 1 unit to left. Instead, my whole view moves by the width of the view to right.

What kind of coordinate system is that? It seems inverted. But also the units don't match with those of for example myView.frame.size.width ?

+2  A: 

anchorPoint is a normalized position within your layer. That is, (0.0, 0.0) is the upper-left corner of your layer (in the iPhone's flipped UIView layer coordinate system) and (1.0, 1.0) is the lower-right corner. (0.5, 0.5) is the middle of your layer. These positions are size-independent, and thus merely relative locations.

This makes it possible to scale about that anchorPoint, which would be confusing to do if anchorPoint was an absolute coordinate.

Brad Larson
Thanks. I had to think about what you mean by normalized position within the layer. But now I get it. These are percentual values.
Thanks
Edit: Well, some sort of percentual. Not really.
Thanks
A fraction of the total length or width would be a pretty close interpretation. This is like what CGColor does, where instead of going from 0 to 255 for each of the RGBA components, it goes from 0.0 to 1.0. "Normalized" is a bit of a technical term.
Brad Larson