Why does my gaze move when I change its center?

I want it to determine the position of the view. But when I change the center property so

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

      

my gaze will move 20 units to the left. I want to change the center point in order to do some rotation about that point.

+1


a source to share


2 answers


If you want to change the pivot point, set the anchorPoint instead. The anchor reference is level in view, but still uses the anchor point when rotated to view.



+6


a source


From Apple API for UIView:

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

Changing the border rectangle to automatically redraw the receiver without calling the drawRect: method. If you want the drawRect: method to be called when the border rectangle changes, set the contentMode property to UIViewContentModeRedraw.



Thus, in essence, change center

, frame

or bounds

will be appropriately resized and resized by changing the corresponding two properties.

+3


a source







All Articles