Why rotating imageView, it changes position?

会有一股神秘感。 提交于 2019-12-12 04:34:03

问题


when I use: ImageView.transform = CGAffineTransformRotate(ImageView.transform, rotation); everytime I rotate imageView and I NSLog(@"x:%f y:%f", ImageView.frame.orgin.x, ImageView.frame.orgin.y), x and y always change value?? Why?


回答1:


Well the .frame.origin is the top left corner of you UIImageView and since you are rotating it the top left corner is moving. If you access the .center it should stay the same.




回答2:


The UIView documentation states that

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

regarding the transform property of a UIView. Since you are assigning to the transform it is most likely not the identity transform any more, hence the frame value is undefined, and should be ignored.



来源:https://stackoverflow.com/questions/13786908/why-rotating-imageview-it-changes-position

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