Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8171813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:34:46+00:00 2026-06-06T21:34:46+00:00

I would like to animate while resizing NSSplitView programatically. Here is the code for

  • 0

I would like to animate while resizing NSSplitView programatically.
Here is the code for resizing the view in SplitView

In awakeFromNib: Iam observing the NSSplitViewWillResizeSubviewsNotification

 [[NSNotificationCenter defaultCenter] addObserver:self
            selector:@selector(splitViewWillResizeSubviewsHandler:)
            name:NSSplitViewWillResizeSubviewsNotification
            object:splitView];

SplitView Resize

NSView * leftSubView = [[splitView subviews] objectAtIndex:0];       
if ([leftSubView isHidden]) 
{
    [leftSubView setHidden:NO];
    [splitView setPosition:0 ofDividerAtIndex:0];
}
else 
{
    [leftSubView setHidden:YES];
}
[splitView adjustSubviews];
    [[NSNotificationCenter defaultCenter] postNotificationName:NSSplitViewWillResizeSubviewsNotification object:self userInfo:nil];

I am able to resize the splitView.Where should I add the animationCode.(As rightView moves to replace the leftSubView, I want the resize happen with some delay) ?

I have the rects of the two Views before and after the resize.Where should I write the animation Code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:34:48+00:00Added an answer on June 6, 2026 at 9:34 pm

    Iam able to solve the animations. Following Code works for me

    -(IBAction)resizeViews:(id)sender
        {
            NSSplitView *splitView = [self splitView];
            NSView * leftSubView = [[splitView subviews] objectAtIndex:0];
            NSView * rightSubView = [[splitView subviews] objectAtIndex:1];
            NSLog(@"splitView Frame %@",NSStringFromRect(splitView.frame));
            NSLog(@"left Frame %@",NSStringFromRect(leftSubView.frame));
            NSLog(@"right Frame %@",NSStringFromRect(rightSubView.frame));
    
            self.lastLeftViewWidth = leftSubView.frame.size.width;
    
            NSMutableDictionary *collapseMainAnimationDict = [NSMutableDictionary dictionaryWithCapacity:2];
            [collapseMainAnimationDict setObject:rightSubView forKey:NSViewAnimationTargetKey];
            NSRect newRightSubViewFrame = rightSubView.frame;
            newRightSubViewFrame.size.width =  splitView.frame.size.width;
            [collapseMainAnimationDict setObject:[NSValue valueWithRect:newRightSubViewFrame] forKey:NSViewAnimationEndFrameKey];
    
            NSMutableDictionary *collapseInspectorAnimationDict = [NSMutableDictionary dictionaryWithCapacity:2];
            [collapseInspectorAnimationDict setObject:leftSubView forKey:NSViewAnimationTargetKey];
            NSRect newLeftSubViewFrame = leftSubView.frame;
            newLeftSubViewFrame.size.width = 0.0f;
            newLeftSubViewFrame.origin.x = splitView.frame.size.width;
            [collapseInspectorAnimationDict setObject:[NSValue valueWithRect:newLeftSubViewFrame] forKey:NSViewAnimationEndFrameKey];
    
            NSViewAnimation *collapseAnimation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:collapseMainAnimationDict, collapseInspectorAnimationDict, nil]];
            [collapseAnimation setDuration:0.60f];
            [collapseAnimation startAnimation];
            [splitView adjustSubviews];
            [splitView setNeedsDisplay:YES];
        }
    
    -(IBAction)normalizeViews:(id)sender
    {
        NSView * left = [[self.splitView subviews] objectAtIndex:0];
        NSView * right = [[self.splitView subviews] objectAtIndex:1];
        NSLog(@"splitView Frame %@",NSStringFromRect( self.splitView.frame));
        NSLog(@"left Frame %@",NSStringFromRect( left.frame));
        NSLog(@"right Frame %@",NSStringFromRect( right.frame));
    //    [right setFrame: NSMakeRect(0, right.frame.origin.y, right.frame.size.width-118, right.frame.size.height)];
    //    [left setFrame:NSMakeRect(0, 0, 118, left.frame.size.height)];
    
        left.hidden = NO;
    
        NSMutableDictionary *expandMainAnimationDict = [NSMutableDictionary dictionaryWithCapacity:2];
        [expandMainAnimationDict setObject:right forKey:NSViewAnimationTargetKey];
        NSRect newMainFrame = right.frame;
        newMainFrame.size.width =  self.splitView.frame.size.width-self.lastLeftViewWidth;
        [expandMainAnimationDict setObject:[NSValue valueWithRect:newMainFrame] forKey:NSViewAnimationEndFrameKey];
    
        NSMutableDictionary *expandInspectorAnimationDict = [NSMutableDictionary dictionaryWithCapacity:2];
        [expandInspectorAnimationDict setObject:left forKey:NSViewAnimationTargetKey];
        NSRect newInspectorFrame = left.frame;
        newInspectorFrame.size.width = self.lastLeftViewWidth;
        newInspectorFrame.origin.x = self.splitView.frame.size.width-self.lastLeftViewWidth;
        [expandInspectorAnimationDict setObject:[NSValue valueWithRect:newInspectorFrame] forKey:NSViewAnimationEndFrameKey];
    
        NSViewAnimation *expandAnimation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:expandMainAnimationDict, expandInspectorAnimationDict, nil]];
        [expandAnimation setDuration:0.60f];
        [expandAnimation startAnimation];
        [self.splitView adjustSubviews];
        [self.splitView setNeedsDisplay:YES];
    }
    

    Following Link helped me in solving the issue

    How to expand and collapse NSSplitView subviews with animation?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to animate a view along a path. While it moves from
I would like to animate movement on a SurfaceView . Ideally I would like
I would like to animate a ScatterView Control using Expression Blend However, it seems
I would like to animate things in 3D space. I know this is possible
I have two views, jumpBarPortrait and jumpBarLandscape I would like to animate between the
I am creating an application that uses popups. However, I would like to animate
I am looking to animate a LinearLayout of mine. I would like to make
Here is my code for a mouseover: $('.caption').mouseover(function() { $(this).fadeTo('slow',1); $(this).css('color','#ddd').animate({'color': 'white'}, 500); $(this).css('font-weight','bold');
I have a UIView that I would like to animate into the screen in
I have been working through some code and I would like to work out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.