1

次のコードを使用してNSImageViewを回転させています(実際には3つ重ねて)回転は正常に機能しますが、回転すると画像が上下に拡大します。なぜ?どうすれば修正できますか?

- (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 に答える