我使用下面的代码来旋转一个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];发布于 2011-01-10 02:19:16
也许用NSImageScaleNone调用- (void)setImageScaling:(NSImageScaling)newScaling;来关闭伸缩?
发布于 2012-12-29 20:54:34
使用:
[anImageView setFrameCenterRotation:angleInDegrees];https://stackoverflow.com/questions/4640723
复制相似问题