MatterGoal
MatterGoal

Reputation: 16430

Animating simultaneously window and view frame in Cocoa

I need to animate a view frame size adding 100px of height, but I need the window grow up simultaneously with the view.

I tried with this code :

    //resize Window
    NSRect winsize = [window frame];
    winsize.size.height += 100;
    [self.window setFrame:winsize display:YES animate:YES];

    //resize View
    NSRect viewsize = [myview frame];
    viewsize.size.height += 100;
    [[myview animator] setFrame:viewsize];

It works but I obtain an ugly effect, Window and View had some delay in resize. Thus, I get the Window frame resizing before than the View frame. How can I modify my code to make them resizing simultaneously ?

add: I found this answer but it tdoesn't seems to work for me: Simultaneously modify window frame and view frame

Upvotes: 1

Views: 517

Answers (1)

MatterGoal
MatterGoal

Reputation: 16430

I found a good solution: using autoresizingMask to mantain min and max Y Margin and allow height resize. [myview setAutoresizingMask:NSViewHeightSizable];

Upvotes: 3

Related Questions