如何使NSWindow setFrame:.. animated:YES]功能动画下来而不是向上?

Rya*_*zel 4 cocoa objective-c nswindow

当我调用我的[window setFrame:frame animated:YES]来放大窗口时,它工作得很好,但它会动画起来并且它会在状态栏后面.如何让窗口生成动画呢?

ugh*_*fhw 13

只需减小y坐标,增加高度即可.

CGFloat amountToIncreaseWidth = 100, amountToIncreaseHeight = 100;
NSRect oldFrame = [window frame];
oldFrame.size.width += amountToIncreaseWidth;
oldFrame.size.height += amountToIncreaseHeight;
oldFrame.origin.y -= amountToIncreaseHeight;
[window setFrame:oldFrame animated:YES];
Run Code Online (Sandbox Code Playgroud)

  • 这使用内置动画. (2认同)