Objective-C 中 NSImageView 之间的转换

发布于 2024-10-04 14:47:58 字数 105 浏览 0 评论 0原文

我对 Mac OS X API 不太熟悉(来自 iPhone sdk 的长期背景),我想知道如何在切换 nsimageviews 时添加过渡。有谁可以分享一段简短的代码片段来说明如何执行此操作吗?

I am not very familiar with the Mac OS X APIs (coming from a long background of iPhone sdk) and I was wondering how I could add a transition when I switch nsimageviews. Does anyone have a short code snippet they can share about how to go about doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入画浅相思 2024-10-11 14:47:59

本教程做了几乎相同的事情,尽管有一些您可能不需要的额外内容:http://www.cimgf.com/2008/03/03/core-animation-tutorial-wizard-dialog-with-transitions/

简而言之,只需调用

[[myWindow contentView] setWantsLayer:YES];
[[[myWindow contentView] animator] replaceSubview:currentView with:newView];

即可对两个视图执行交叉淡入淡出动画。如果您想做不同类型的动画,教程中的第四个代码块应该会有帮助。

请注意,使用核心动画层会破坏字体渲染,因此您可能还需要在动画完成后setWantsLayer:NO

This tutorial does pretty much the same thing, albeit with some extra things you probably don't need: http://www.cimgf.com/2008/03/03/core-animation-tutorial-wizard-dialog-with-transitions/

In short, just call

[[myWindow contentView] setWantsLayer:YES];
[[[myWindow contentView] animator] replaceSubview:currentView with:newView];

to do a crossfade animation of the two views. If you want to do a different type of animation, the fourth block of code in the tutorial should be of help.

Be warned that using Core Animation layers ruins your font rendering, so you'll probably want to setWantsLayer:NO after the animation is complete also.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文