我有两个滑块 - 一个用于更改图像大小,一个用于旋转此图像。我的图像视图是 60x60。问题是我使用 CGAffineTransformMakeRotation 旋转图像,但是当我尝试在此之后调整它的大小(例如,使用滑块从 60x60 到 65x65)时,它的行为很奇怪 - 图像视图的框架已经改变为 80x2。我怎样才能避免这种情况?这是我调整图像大小的滑块的代码:
-(IBAction)imageSliderAction:(UISlider *)sender
{
NSUInteger value = sender.value;
float oldCenterX = logoImageView.center.x;
float oldCenterY = logoImageView.center.y;
newWidth = value;
newHeight = value;
CGRect frame = [logoImageView frame];
frame.size.width = newWidth;
frame.size.height = newHeight;
[logoImageView setFrame:frame];
logoImageView.center = CGPointMake(oldCenterX, oldCenterY);
}
这是我的旋转滑块的代码:
-(IBAction)rotationSliderAction:(UISlider *)sender
{
NSUInteger angle = sender.value;
if (sender.value >= 1)
{
CGAffineTransform rotate = CGAffineTransformMakeRotation(angle / 180.0 * 3.14);
[logoImageView setTransform:rotate];
}
if (sender.value <= 0 )
{
CGAffineTransform rotate = CGAffineTransformMakeRotation( (360 + sender.value) / 180.0 * 3.14);
[logoImageView setTransform:rotate];
}
}
旋转时如何避免自动更改框架的宽度和高度?因为在那之后我无法正确调整图像大小。