Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top