For some reason, none of the frame animation methods worked for my scrollview. However, I did not try to revive the restrictions.
In the end, I created a custom animation to animate the position of the separator. If anyone is interested, here is my solution:
Animation .h:
@interface MySplitViewAnimation : NSAnimation <NSAnimationDelegate> @property (nonatomic, strong) NSSplitView* splitView; @property (nonatomic) NSInteger dividerIndex; @property (nonatomic) float startPosition; @property (nonatomic) float endPosition; @property (nonatomic, strong) void (^completionBlock)(); - (instancetype)initWithSplitView:(NSSplitView*)splitView dividerAtIndex:(NSInteger)dividerIndex from:(float)startPosition to:(float)endPosition completionBlock:(void (^)())completionBlock; @end
Animation .m
@implementation MySplitViewAnimation - (instancetype)initWithSplitView:(NSSplitView*)splitView dividerAtIndex:(NSInteger)dividerIndex from:(float)startPosition to:(float)endPosition completionBlock:(void (^)())completionBlock; { if (self = [super init]) { self.splitView = splitView; self.dividerIndex = dividerIndex; self.startPosition = startPosition; self.endPosition = endPosition; self.completionBlock = completionBlock; [self setDuration:0.333333]; [self setAnimationBlockingMode:NSAnimationNonblocking]; [self setAnimationCurve:NSAnimationEaseIn]; [self setFrameRate:30.0]; [self setDelegate:self]; } return self; } - (void)setCurrentProgress:(NSAnimationProgress)progress { [super setCurrentProgress:progress]; float newPosition = self.startPosition + ((self.endPosition - self.startPosition) * progress); [self.splitView setPosition:newPosition ofDividerAtIndex:self.dividerIndex]; if (progress == 1.0) { self.completionBlock(); } } @end
I use it like this: I have a view divided by 3 panels, and I move the right panel to / from a fixed amount (235).
- (IBAction)togglePropertiesPane:(id)sender { if (self.rightPane.isHidden) { self.rightPane.hidden = NO; [[[MySplitViewAnimation alloc] initWithSplitView:_splitView dividerAtIndex:1 from:_splitView.frame.size.width to:_splitView.frame.size.width - 235 completionBlock:^{ ; }] startAnimation]; } else { [[[MySplitViewAnimation alloc] initWithSplitView:_splitView dividerAtIndex:1 from:_splitView.frame.size.width - 235 to:_splitView.frame.size.width completionBlock:^{ self.rightPane.hidden = YES; }] startAnimation]; } }
source share