views:

79

answers:

3

How would I change from one view to another with a slide transition?

Thanks.

+1  A: 

Place them side by side, and use NSViewAnimation to perform the animation.

This may turn out tricky if the views' size can change. Doubly so if the two views are not the same size as each other.

Peter Hosey
Thanks, I didn't do it like you said (side by side), instead I found this article with another easy way to do it. http://bish.fr/5vyr.
Joshua
A: 

Implement all the actual drawing using CALayers. (Having not used Core Animation myself, I can't get more specific.) Put them in a single view, hosting that layer hierarchy, and use Core Animation to perform the slide transition.

This may not work so well if the views are not display-only—that is, if they host controls that the user can interact with. Layers are more or less display-only, since you can't put a view in a layer, and only views, not layers, are responders.

Peter Hosey
+1  A: 

Marcus Zarra gives a good example of how to use Core Animation to achieve this effect in his post on how to implement a wizard. It's very simple to do using subviews and a CATransition.

Brad Larson
That's a good example and almost works except in the second view everything doesn't work. In the second view I have a web view and it is completely blank even though I know content is there. Here is a video showing it … http://fwdr.org/z9tf.
Joshua
Unfortunately, WebViews can't be layer-backed on the Mac, so they won't play nice with Core Animation: http://stackoverflow.com/questions/1618498/webview-in-core-animation-layer . If that's your case, I'd follow Peter's suggestion of using NSViewAnimation.
Brad Larson