Reputation: 18253
Mail.app has a small activity pane in the lower left corner that slides in when activated. I noticed that it re-dimensions the source list above it during the animation (the scroll bar resizes concurrently).
How can that be achieved? I have not found a built-in way to animate view frames the same way you can do for windows.
Upvotes: 1
Views: 549
Reputation: 3919
You can use Core Animation. An example of frame changing with Core Animation is shown here: http://www.macresearch.org/tutorial-intro-core-animation
You can also use NSViewAnimation to do the animation, as shown here: http://www.cocoadev.com/index.pl?AnimatedNSSplitView
A third way is to do this yourself using GCD:
CGFloat duration = 2; //animation duration (seconds)
int N = 100; //animation fineness
CGFloat dt = duration/N; //time change
dispatch_async(dispatch_get_global_queue(0,0), ^{
for (int i = 1; i <= N; i++)
{
NSDate *future = [NSDate dateWithTimeIntervalSinceNow:dt];
[NSThread sleepUntilDate:future];
//calculate your new frame/splitview setup
dispatch_async(dispatch_get_main_queue(), ^{
//apply the new frame/splitview setup
});
}
});
Upvotes: 2