views:

958

answers:

2

I rotate/scale a UIVIew using [UIView transform:] and this works well. However, as soon as I change the view's frame origin the contents of the view begins to scale 'weirdly' even though I am not performing any further CGAffineTransforms.

Why does this occur? How can I prevent it?

Update 1:

The docs suggest that the frame is invalid after a transform. Can I move the view via it's 'center' property instead?

Update 2:

Setting the views center did allow me to translate the view successfully after a transform had been applied.

+1  A: 

From the UIView docs:

transform:

Warning: If this property is not the identity transform, the value of the frame property is undefined and therefore should be ignored.

The center property is just a convenience method that really resets the frame's origin.

Edit: appended to answer comment:

If you're using the transform property and want to reposition your view, you have to concatenate the translation to your transform using:

view.transform = CGAffineTransformTranslate(view.transform, tx, tx);
Nikolai Ruhe
I which case - how can I reposition the view?
teabot
I did try translating the view with an affine transformation but that created lots of complications which required me to manipulate the views anchor point.
teabot
+2  A: 

Can I move the view via it's 'center' property instead?

The documentation defines the center property as:

The center of the frame.

and says:

The center is specified within the coordinate system of its superview.

I'd try it.

Peter Hosey
Tried it - it worked.
teabot