简体   繁体   English

UIImageView在旋转时会改变其宽度和高度,如何获得原始高度和宽度的正常状态?

[英]UIImageView on rotating changes it width and height, how to get original height and width of normal state?

I have an image of width 200 and height 200 .when I rotate it to some degree say 60 degree then new width and height comes out to be 273,273 . 我有一个宽度为200高度为200的图像。当我将其旋转某种程度(例如60度)时, 新的宽度和高度273,273

But I want to retrieve the same height and width 200*200 whatever rotation it has. 但是无论旋转多少,我都希望检索相同的高度和宽度200 * 200

I am trying to scale that image to some ratio of back view size on which that image is placed. 我正在尝试将该图像缩放到放置该图像的后视尺寸的一定比例。 If back view reduces to half the image size is also reduced to half and same way if back view is increased to double image also increased to double. 如果后视图减小到一半,则图像大小也将减小到一半;如果后视图增大为两倍,则图像尺寸也将减小为一半。 But when I rotate the image and try to change the frame of back view that image resizing works fine if it's not rotated but if it's rotated then resizing of back view ratio will not work fine with image ratio. 但是,当我旋转图像并尝试更改后视图的框架时,如果不旋转图像调整大小效果很好,但是如果旋转了,则调整后视比例的大小就无法使用图像比例。 Image either increase more or decrease. 图像增加或减少。 Generally it increases more than expected. 通常,它的增长超过预期。

旋转后view.bounds.size不会改变

Image.transform=CGAffineTransformMakeRotation(angle); Image.transform = CGAffineTransformMakeRotation(angle); works perfectly fine . 工作很好。 Check your image .... if it is in ping or jpeg etc. The issue is with the image I think not with the method .. :) 检查您的图像.....是否为ping或jpeg等。问题出在图像上,我认为不是方法.. :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM