简体   繁体   English

旋转和调整图像大小+ iPhone

[英]Rotation and resizing the image + iPhone

I am trying to resize and rotate an image over the iPhone. 我正在尝试调整大小并在iPhone上旋转图像。 i picked the image and displayed it using UIImageView 我选择了图像并使用UIImageView显示了它

and rotation of the image is done by two buttons (for clockwise & counterclockwise) 并通过两个按钮(顺时针和逆时针)旋转图像

resizing of image works fine while rotation button not pressed but when i pressed to rotate image into clockwise direction and the resize the image, width of the image increases rapidly even i am trying to decrease the width. 在未按下旋转按钮的情况下,调整图像大小的效果很好,但是当我按下将图像按顺时针方向旋转并调整图像大小时,即使我试图减小宽度,图像的宽度也会迅速增加。

and when i pressed to rotate image into counterclockwise direction and the resize the image, height of the image increases rapidly even i am trying to decrease it. 当我按下将图像旋转到逆时针方向并调整图像大小时,即使我试图减小图像的高度,图像的高度也会迅速增加。

i found that there is some sign changed while rotating the image along with the value, coz once press the clockwise button and then counterclockwise button, and then resizing works fine. 我发现在旋转图像和值时有一些符号更改,因为一次按顺时针按钮然后按逆时针按钮,然后调整大小效果很好。

i used the following code for rotating the image. 我使用以下代码旋转图像。

CGAffineTransform transformRotate = CGAffineTransformMakeRotation(movingAngle);
imageViewRotation.transform = transformRotate;

where movingAngle is in Radians and imageViewRotation is the UIImageView which contains the image. 其中moveAngle在弧度中,而imageViewRotation是包含图像的UIImageView。

waiting for your reply 等待你的答复

You can make this happen smoother by making it an animation: 您可以通过将其设置为动画来使此过程更平滑:

[UIView beginAnimations:nil contextNULL];
[UIView setAnimationDuration:.5;

CGAffineTransform transformRotate = CGAffineTransformMakeRotation(movingAngle); 
imageViewRotation.transform = transformRotate;

CGRect frame = /*make the new frame or set it to -->*/self.view.frame;
imageViewRotation.frame = newFrame;

[UIView commitAnimations];

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

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