views:

90

answers:

2

I thoght that it's frame's oringin decides the position of the view. But when I change the center property like so

myView.center = CGPointMake(myView.center.x - 20, myView.center.y);

my view will move 20 units to left. I want to change the center point to make some rotations relative to that point.

+3  A: 

From the Apple API for UIView:

The center is specified within the coordinate system of its superview. Setting this property changes the values of the frame properties accordingly.

Changing the frame rectangle automatically redisplay the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw.

So essentially, changing either center, frame, or bounds will reposition and resize the view appropriately, changing the other two properties accordingly.

Marc W
So this means, that it's impossible to set the center point somewhere else than the center of the view, as it will always be corrected automatically, right?
Thanks
That is correct. It will always represent the center of the view no matter what you do.
Marc W
+5  A: 

If you want to change the rotation point, set the anchorPoint instead. The anchorPoint is on the layer in the view, but the rotation applied to the view still uses the anchor point.

Ed Marty