Animating NSSplitView collapse/uncollapse
Animating NSSplitView collapse/uncollapse
- Subject: Animating NSSplitView collapse/uncollapse
- From: Luc Van Bogaert <email@hidden>
- Date: Sun, 05 Feb 2012 21:59:22 +0100
I've been trying to implement a splitview with animated collapse/uncollapse of one of its subviews. So far without success, although I think I'm very close to a working solution. There's a lot of documentation and sample code on the internet, but none of what I have found seems to fit my needs.
Currently, this is the code that does the animation (in a NSSplitView subclass) :
- (void)animateDividerToPosition:(CGFloat)dividerPosition
{
NSView *view0 = [[self subviews] objectAtIndex:0];
NSView *view1 = [[self subviews] objectAtIndex:1];
NSRect view0Rect = [view0 frame];
NSRect view1Rect = [view1 frame];
NSRect overalRect = [self frame];
CGFloat dividerThickness = [self dividerThickness];
if ([self isVertical]) {
view0Rect.size.width = dividerPosition;
view1Rect.origin.x = dividerPosition + dividerThickness;
view1Rect.size.width = overalRect.size.width - view0Rect.size.width - dividerThickness;
} else {
view0Rect.size.height = dividerPosition;
view1Rect.origin.y = dividerPosition + dividerThickness;
view1Rect.size.height = overalRect.size.height - view0Rect.size.height - dividerThickness;
}
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.3];
[[view0 animator] setFrame: view0Rect];
[[view1 animator] setFrame: view1Rect];
[NSAnimationContext endGrouping];
}
Collapse seems to work fine this way, but when I uncollapse a subview, the views contents are only drawn partially, similar to the effect one sees when the splitview delegate does not implement the methods to constrain the subview size.
Any ideas?
Thanks
--
Luc Van Bogaert
_______________________________________________
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