1

我正在使用以下代码旋转一个 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];
4

2 回答 2

3

利用:

[anImageView setFrameCenterRotation:angleInDegrees];
于 2012-12-29T12:54:34.270 回答
1

也许调用 - (void)setImageScaling:(NSImageScaling)newScaling; 用 NSImageScaleNone 关闭缩放?

于 2011-01-09T18:19:15.927 回答