How to disable Cocoa default animation when displaying modal sheet?

I would like to disable the animation that Cocoa performs when displaying a modal sheet.

Apple Sheet Programming Guide :

... Other sheet behavior, such as animation, when it appears and is fired, is processed automatically using a set of applications.

But he does not give any instructions on how to turn off this effect.

I created my own sheet (a subclass of NSWindow with a transparent background and some controls in it). I can display it using the standard beginSheet method as follows:

[NSApp beginSheet:myCustomSheet
   modalForWindow:mainWindow
    modalDelegate:self
   didEndSelector:...];

The sheet displays fine, but it goes through the animation when it appears, and again when it closes.

.. /, Apple .

+3
2

. , , 0.

+1

( , ), Core Animation. , :

[CATransaction begin];
[CATransaction setValue: [NSNumber numberWithBool: YES]
    forKey: kCATransactionDisableActions ];
[NSApp beginSheet:myCustomSheet
   modalForWindow:mainWindow
    modalDelegate:self
   didEndSelector:...];
[CATransaction commit];
0

Source: https://habr.com/ru/post/1758305/


All Articles