1

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

Thanks.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Joshua
  • 15,200
  • 21
  • 100
  • 172

3 Answers3

2

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
  • 95,783
  • 15
  • 211
  • 370
  • 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 Dec 15 '09 at 19:00
1

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
  • 170,088
  • 45
  • 397
  • 571
  • 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 Dec 15 '09 at 16:26
  • 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 Dec 15 '09 at 18:08
0

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
  • 95,783
  • 15
  • 211
  • 370