Cocoa - 显示时的NSWindow动画? [英] Cocoa - NSWindow animation when displayed?

查看:282
本文介绍了Cocoa - 显示时的NSWindow动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当显示一个简单的nswindow时,如何添加某种CoreAnimation效果?

How would I add some sort of CoreAnimation effect when showing a simple nswindow?

感谢

推荐答案

我做了一个像你之前描述的动画。然而,这不是一个容易的任务。由于您的动画延伸到窗口本身的边界之外,因此您需要在一个超大,透明的窗口中渲染动画。动画完成后,您可以在实际窗口中订购,并移除透明的窗口。

I've done an animation like you describe before. However, it wasn't an easy task. Since your animation extends outside the bounds of the window itself, you'll need to render the animation in an oversized, transparent window. When the animation completes, you can order in the real window and remove the transparent one.

您需要一个窗口图片作为动画内容,所以我会做的是订购窗口(也可能使它的关键窗口,所以它看起来集中),但把它很好的屏幕,所以用户不看到它。然后使用 CGWindowListCreateImage 抓取窗口的屏幕截图。

You'll need an image of the window to use as the content of your animation, so what I would do is order the window in (and probably make it the key window, too, so that it looks focused), but put it well off-screen so the user doesn't see it. Then use CGWindowListCreateImage to grab a screenshot of the window. Now you'll have what you need to create an animation.

动画完成后,只需将实际窗口排在透明窗口上方,然后移除透明窗口即可。得到数学,使动画和真实窗口中的窗口的图像有点棘手,但它绝对是可行的。

After the animation completes, just order the real window over top of the transparent one, then remove the transparent window. Getting the math right so that the image of the window in the animation and the real window is a bit tricky, but it's definitely doable.

这篇关于Cocoa - 显示时的NSWindow动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆