Reputation: 15444
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.
Upvotes: 2
Views: 2814
Reputation: 81848
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);
Upvotes: 1
Reputation: 96323
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.
Upvotes: 3