我想让视图在窗口调整大小时移动到不同的位置。我目前在接收 NSWindowDidResizeNotification 时使用 NSViewAnimation 执行此操作。
// Create the view animation object.
theAnim = [[NSViewAnimation alloc] initWithViewAnimations:animation];
// Set some additional attributes for the animation.
[theAnim setDuration:1]; // One and a half seconds.
[theAnim setAnimationCurve:NSAnimationEaseIn];
[theAnim setFrameRate:20.0];
[theAnim setAnimationBlockingMode:NSAnimationNonblocking];
// Run the animation.
[theAnim startAnimation];
// The animation has finished, so go ahead and release it.
[theAnim release];
(“动画”是一个数组,其中包含我的视图的新矩形,就像 NSAnimation 想要的那样)当我调整窗口大小时,此代码被多次调用。因此,在调整大小时,此代码会被调用大约 20 次以调整大小。我现在有 20 个视图移动的动画。20 个不同的重叠。(看起来有很多不同的视图,但我认为动画之间的跳跃是一样的)
在 iPhone 上,只有视图在移动,我可以设置 [UIView setAnimationBeginsFromCurrentState:YES] 并且它会起作用。有没有办法在 OSX 上做到这一点?我可以在视图上创建一个 isAnimating 变量,但它只会移动到一个位置,并且在制作动画时会忽略快速调整大小。
我如何在 OSX 上执行此操作?谢谢