本文介绍了旋转NSImageView导致NSImageView缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码旋转NSImageView(实际上是三个堆叠在一起),旋转效果很好,但是图像在旋转时会按比例放大和缩小.为什么?以及我该如何解决?
I am using the following code to rotate a NSImageView (actually three stacked on top of each other) the rotation works fine, but the image scales up and down when it rotates. why? and how can i fix it?
- (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
Solved!
instead of rotating each NSImageView i just rotated the whole NSView containing all the ImageViews =D
代码:
[self setFrameCenterRotation:-priorResult];
[self setFrameCenterRotation:rot];
[self setNeedsDisplay:YES];
推荐答案
也许调用-(void)setImageScaling:(NSImageScaling)newScaling;用NSImageScaleNone关闭缩放功能?
Perhaps call - (void)setImageScaling:(NSImageScaling)newScaling;with NSImageScaleNone to turn off scaling?
这篇关于旋转NSImageView导致NSImageView缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!