简体   繁体   English

以编程方式创建的NSWindow调整大小缓慢

[英]Programmatically-created NSWindow slow to resize

If I create an NSWindow by hand: 如果我手动创建一个NSWindow

NSWindow* window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 600, 500)
                                               styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable
                                                 backing:NSBackingStoreBuffered defer:YES];

…then resizing it is slow and laggy compared to a window from a Storyboard. …与调整情节提要的窗口相比,调整大小既缓慢又漫长。 Why? 为什么?

Give the window's content view a layer: 给窗口的内容视图添加一层:

window.contentView.wantsLayer = YES;

This is the default for Storyboard windows: 这是Storyboard窗口的默认设置:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM