我尝试旋转图像:
UIImageView *image;
image.transform = CGAffineTransformMakeRotation(0.0175*degrees);
// 0.0175 = pi/180 = 1 degree in radians
如果是
degrees = 90*x // x = 1,2,3,4
没关系,但是当degrees = 45
图像突然变得非常薄,而在其他情况下它也会拉伸或收缩。
这可能是什么原因?
我也试过
CGAffineTransform transform=CGAffineTransformRotate(image.transform, degrees);
image.transform = transform;
有类似的结果。
编辑:我也试过image.contentMode = UIViewContentModeScaleAspectFill;
,但后来变得很大
答案 0 :(得分:1)
你设置了界限和中心吗?尝试这样,但使用您的指标:
CGRect bounds = CGRectMake(0, 0, 20, 200);
CGPoint center = CGPointMake(myrectr.origin.x + (bounds.size.width / 2.0f),
imageViewRect.origin.y + (bounds.size.height / 2.0f) + 100.0f);
[imageView setTransform:CGAffineTransformIdentity];
[imageView setCenter:center];
[imageView setBounds:bounds];
[imageView setTransform:CGAffineTransformMakeRotation(M_PI / 4.0f)];