简体   繁体   中英

Programmatically-created NSWindow slow to resize

If I create an NSWindow by hand:

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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