gpt4 book ai didi

cocoa - 有没有办法让 NSAnimation "Begin from current state"就像在 iPhone 上一样?

转载 作者:行者123 更新时间:2023-12-03 16:33:40 25 4
gpt4 key购买 nike

我想让 View 在窗口调整大小时移动到不同的位置。我目前在接收 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];

(“animation”是一个带有字典的数组,其中包含我的 View 的新矩形,就像 NSAnimation 想要的那样)当我调整窗口大小时,会多次调用此代码。因此,在调整大小时,对于一次调整大小,此代码将被调用大约 20 次。我现在有 20 个 View 移动动画。 20 个不同的重叠。 (看起来有很多不同的 View ,但我认为在动画之间跳跃是同一个 View )

在 iPhone 上,只有 View 在移动,我可以设置 [UIView setAnimationBeginsFromCurrentState:YES] 并且它会起作用。有没有办法在 OSX 上做到这一点?我可以在 View 上创建一个 isAnimating 变量,但随后它只会移动到一个位置,并且会在动画时忽略快速调整大小。

如何在 OSX 上执行此操作?谢谢

最佳答案

我刚刚做了一个 [[album.view animator] setFrame:newFrame];它就搬到了那里。美丽的。(我可以补充一下这有多神奇!)

关于cocoa - 有没有办法让 NSAnimation "Begin from current state"就像在 iPhone 上一样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4816518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com