• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using CoreAnimation to Show/Hide a SplitView Pane
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using CoreAnimation to Show/Hide a SplitView Pane


  • Subject: Using CoreAnimation to Show/Hide a SplitView Pane
  • From: Jonathan Dann <email@hidden>
  • Date: Sun, 23 Mar 2008 23:39:10 +0000

Hi All,

I've managed to do the above with NSAnimation, but I'm trying to do the same using Core Animation.

AFAIK To hide a split view pane when the user clicks a button, you need to set the frame's height/width to zero and move the divider when the animation has finished. When using an implicit animation on the view's frame I can't see how to get a notification that the animation has ended. If I do the following:

// horizontal splitView
[[subview animator] setFrame:newFrame];
[splitView setPosition:[splitView maxPossiblePositionOfDividerAtIndex: 0] ofDividerAtIndex:0];


the animation is not shown as the divider causes the subview to 'snap' shut immediately. With NSAnimation you can set the delegate and move the split view bar in the -animationDidEnd: method.

To do the same with Core Animation I've tried to set up my own CABasicAnimation, but I can't get it to work, and the Programming Guide isn't clearing up the matter for me. I've tried this so far:

- (IBAction)hide:(id)sender {
NSScrollView *scrollView = self.splitView.subviews.secondObject; // - secondObject is my own NSArray method and the scrollView is the lower of a horizontal two-pane split view;


	NSRect toValue = scrollView.frame;
	toValue.size.height = 0.0;

CABasicAnimation *hidePaneAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
[hidePaneAnimation setRemovedOnCompletion:NO];
[hidePaneAnimation setFillMode:kCAFillModeForwards];
[hidePaneAnimation setToValue:[NSValue valueWithRect:toValue]];
[hidePaneAnimation setFromValue:[NSValue valueWithRect:[scrollView frame]]];
[hidePaneAnimation setDelegate:self];
[scrollView setWantsLayer:YES];
[scrollView setLayer:[CALayer layer]];
[[scrollView layer] addAnimation:hidePaneAnimation forKey:@"positionAnimation"];
}


- (void)animationDidStop:(CAAnimation *)animation finished: (BOOL)finished;
{
NSLog(@"%p %s %@ Finished: %i",self,__func__,animation,finished);
NSString *keyPath = [(CABasicAnimation *)animation keyPath];
NSLog(@"key %@",keyPath);
NSSplitView *splitView = (NSSplitView *)self.view;
CALayer *layer = [splitView.subviews.secondObject layer];
[layer setValue:[(CABasicAnimation *)animation toValue] forKeyPath:keyPath];
[layer removeAnimationForKey:keyPath];
[splitView setPosition:[splitView maxPossiblePositionOfDividerAtIndex: 0] ofDividerAtIndex:0];
}


Currently this just causes the pane to snap shut and flicker a little. Can anybody give me a hand with this, please?

Thanks,

Jonathan



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

  • Prev by Date: Re: How to add a column of NSButtonCells to an NSOutlineView in InterfaceBuilder?
  • Next by Date: NSTreeController / CoreData still broken in 10.5?
  • Previous by thread: Re: Notification when a volume is renamed?
  • Next by thread: NSTreeController / CoreData still broken in 10.5?
  • Index(es):
    • Date
    • Thread