Ich versuche das Collapse Verhalten eines NSSplitViews zu animieren wenn man auf einen Button klickt. Jedoch funktioniert es leider nicht.
Was ist mein Fehler ? Kann mir jemand helfen ?
Alles anzeigen
Was ist mein Fehler ? Kann mir jemand helfen ?
Quellcode
- -(IBAction)toggle:(id)sender{
- if ([self isSubviewCollapsed:[[self subviews] objectAtIndex:0]]) {
- NSView* topView = [[self subviews] objectAtIndex:0];
- NSView* bottomView = [[self subviews] objectAtIndex:1];
- NSMutableDictionary* expandBottomViewDict = [NSMutableDictionary dictionaryWithCapacity:2];
- [expandBottomViewDict setObject:bottomView forKey:NSViewAnimationTargetKey];
- NSRect newBottomFrame = bottomView.frame;
- newBottomFrame.size.height = self.frame.size.height -130;
- [expandBottomViewDict setObject:[NSValue valueWithRect:newBottomFrame] forKey:NSViewAnimationEndFrameKey];
- NSMutableDictionary* expandTopViewDict = [NSMutableDictionary dictionaryWithCapacity:2];
- [expandTopViewDict setObject:topView forKey:NSViewAnimationTargetKey];
- NSRect newTopViewFrame = topView.frame;
- newTopViewFrame.size.height = 120;
- newTopViewFrame.origin.y = self.frame.size.height;
- [expandTopViewDict setObject:[NSValue valueWithRect:newTopViewFrame] forKey:NSViewAnimationEndFrameKey];
- NSViewAnimation *expandAnimation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:expandBottomViewDict, expandTopViewDict, nil]];
- [expandAnimation setDuration:0.25f];
- [expandAnimation startAnimation];
- }
- }