开发者

Transition between NSImageViews in Objective-C

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开发者_Go百科 to go about doing this?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜