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];
win开发者_如何学Csize.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
I found a good solution: using autoresizingMask to mantain min and max Y Margin and allow height resize.
[myview setAutoresizingMask:NSViewHeightSizable];
精彩评论