为什么旋转imageView,它的位置会改变?[英] Why rotating imageView, it changes position?

本文是小编为大家收集整理的关于为什么旋转imageView,它的位置会改变?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

当我使用时:imageView.transform = cgaffinetransformrotate(imageView.transform,旋转);每次我旋转imageView和i nslog(@x:%f y:%f",imageview.frame.orgin.x,imageview.frame.orgin.y),x和y总是更改值?为什么?

推荐答案

好吧,.frame.origin是您UIImageView的左上角,并且由于您旋转它,因此左上角正在移动.如果您访问.center它应该保持不变.

其他推荐答案

uiview 属性不是身份变换,则框架属性的值是未定义的,因此应忽略.

关于Uiview的转换属性.由于您正在分配转换,因此很可能不再是身份变换,因此帧值不确定,应忽略.

本文地址:https://www.itbaoku.cn/post/2091181.html

问题描述

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?

推荐答案

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.

其他推荐答案

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.