Created
February 8, 2022 01:26
-
-
Save monyschuk/5e5321c30aa06d319106d7ae3b4a2f1e to your computer and use it in GitHub Desktop.
disables all animation of NSPopover (for use in SwiftUI apps where there is no control over popover display animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSPopover_OverrideAnimation.h | |
// scrl (macOS) | |
// | |
// Created by Mark Onyschuk on 2022-02-07. | |
// | |
#import <Cocoa/Cocoa.h> | |
NS_ASSUME_NONNULL_BEGIN | |
@interface NSPopover (NSPopover_Override) | |
@end | |
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSPopover_OverrideAnimation.m | |
// scrl (macOS) | |
// | |
// Created by Mark Onyschuk on 2022-02-07. | |
// | |
#import "NSPopover_OverrideAnimation.h" | |
#import <objc/runtime.h> | |
@implementation NSPopover (NSPopover_OverrideAnimation) | |
+ (void)load { | |
Method mold = class_getInstanceMethod(self, @selector(animates)); | |
Method mnew = class_getInstanceMethod(self, @selector(swizzled_animates)); | |
if (mold != nil && mnew != nil) { | |
method_exchangeImplementations(mold, mnew); | |
} | |
} | |
- (BOOL)swizzled_animates { | |
return NO; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment