How can I slide a view in and out of a window in a Cocoa program?

CoreAnimation is definitely your best bet. It has been a while since I've worked with any CA code, but something like.

CoreAnimation is definitely your best bet. It has been a while since I've worked with any CA code, but something like: UIView beginAnimations:@"slideOn" context:nil; firstView. Frame = shrunkFirstViewRect; // The rect defining the first view's smaller frame.

This should resize the first view secondView. Frame = secondViewOnScreenFrame; // This should move the second view on the frame. UIView commitAnimations; Later, you could return to a single view using: UIView beginAnimations:@"slideOff" context:nil; firstView.

Frame = normalFirstViewRect; // The rect defining the first view's normal frame. This should expand the first view. SecondView.

Frame = secondViewOffScreenFrame; // Move the second view off the screen UIView commitAnimations; Edit: The above code is for the iPhone, I read your question a bit quick. On the Mac, you would want to use (similarly): NSAnimationContext beginGrouping; NSAnimationContext currentContext setDuration:1.0f; // However long you want the slide to take firstView animator setFrame:shrunkFirstViewRect; secondView animator setFrame:secondViewOnScreenFrame; NSAnimationContext endGrouping.

1 UIKit is only available on the iPhone, not the Mac. On the Mac, you'd need to use NSAnimationContext for the grouping, and eachView.animator. Frame instead of eachView.frame.

– Peter Hosey Apr 7 '09 at 18:58 Good call, I didn't catch the note at the bottom. Updated answer, thanks! – craig Apr 7 '09 at 19:07 Thanks all.

I'll give it a try. – Abizern Apr 9 '09 at 18:26.

I have never tried, but I think that CoreAnimation has interesting features for this. You have to animate height of view1 from full height to half height and position of view2 from outside its superview to top half of it.

It should be noted if you don't set a duration for the animation block, the default is about 0.25 seconds, which actually seems to work very well in most cases. I suggest trying with that duration first whenever experimenting with CoreAnimation.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions