Resetting the origin of a transformed UIView descends into craziness

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 21:58:40

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.

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!