Re: Window Animation with setFrame:display:animate: Flickers
Re: Window Animation with setFrame:display:animate: Flickers
- Subject: Re: Window Animation with setFrame:display:animate: Flickers
- From: Markus Spoettl <email@hidden>
- Date: Sat, 21 Feb 2009 20:58:50 +0100
On Feb 21, 2009, at 8:03 PM, K. Darcy Otto wrote:
I had considered doing this with Core Animation, but it just seems
simpler to get this working. Here is the code that I'm using
(adapted from Hillegass, Chapter 29):
-(void)displayViewController:(NSViewController *)vc
{
NSWindow *w = [self window];
NSView *v = [vc view];
// Compute the new window frame
NSSize currentSize = [[w contentView] frame].size;
NSSize newSize = [v frame].size;
float deltaWidth = newSize.width - currentSize.width;
float deltaHeight = newSize.height - currentSize.height;
NSRect windowFrame = [w frame];
windowFrame.size.height += deltaHeight;
windowFrame.origin.y -= deltaHeight;
windowFrame.size.width += deltaWidth;
[w setContentView:nil];
[w setFrame:windowFrame display:YES animate:YES];
[w setContentView:v];
}
You probably shouldn't replace the content view with your own view.
The content view is a container that is managed by the window (resized
to the window's specifications as the window resizes, for example).
Instead of replacing it you probably want to add your view as a sub-
view of the content view, something like this:
// todo: set this up to your liking
NSRect contentBounds = [[w contentView] bounds];
// fill content view entirely
[v setFrame:contentBounds];
// adjust width and height to content view/window
[v setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[[w contentView] addSubview:v];
[w setFrame:windowFrame display:YES animate:YES];
Warning, programmed in Mail.app
Markus
--
__________________________________________
Markus Spoettl
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden