我正在使用以下代码旋转NSImageView(实际上三个堆叠在一起),旋转工作正常,但图像在旋转时会上下缩放。为什么?我该如何解决?
- (void)UpdateRotate:(CGPoint)mouseLoc{
mouseLoc.y = mouseLoc.y - 200;
CGPoint playerMid = CGPointMake(prect.xPos, prect.yPos);
x = mouseLoc.x - playerMid.x;
y = mouseLoc.y - playerMid.y;
double priorResult = rot;
rot = atan2(y,x) * 180 / PI;
[image rotateByAngle:-priorResult];
[image rotateByAngle:rot];
[image setNeedsDisplay:YES];
[WeaponImage rotateByAngle:-priorResult];
[WeaponImage rotateByAngle:rot];
[WeaponImage setNeedsDisplay:YES];
[ShieldImage rotateByAngle:-priorResult];
[ShieldImage rotateByAngle:rot];
[ShieldImage setNeedsDisplay:YES];
}
而不是旋转每个NSImageView我只是旋转了包含所有ImageViews = D的整个NSView
代码:
[self setFrameCenterRotation:-priorResult];
[self setFrameCenterRotation:rot];
[self setNeedsDisplay:YES];
答案 0 :(得分:3)
使用:
[anImageView setFrameCenterRotation:angleInDegrees];
答案 1 :(得分:1)
也许调用 - (void)setImageScaling:(NSImageScaling)newScaling; 使用NSImageScaleNone来关闭缩放?