Last active
February 6, 2022 14:53
-
-
Save steipete/b8bf675028ee476a9ca9af1ff14ff1e0 to your computer and use it in GitHub Desktop.
iOSMac Marzipan Toolbar Access. Learn more at https://speakerdeck.com/steipete/hacking-marzipan
This file contains hidden or 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
import Foundation | |
class iOSMacToolbarController { | |
init() { | |
print("iOSMac Marzipan extensions initializing.") | |
guard (NSClassFromString("_UIWindowToolbarButtonItem") != nil) else { | |
print("iOSMac UIKit Extensions not found.") | |
return } | |
let titleButton = _UIWindowToolbarButtonItem(identifier: "com.pspdfkit.viewer.test") | |
titleButton?.title = "A button" | |
guard let toolbarController = UIApplication.shared.keyWindow!.value(forKey: "_windowToolbarController") as? _UIWindowToolbarController else { | |
print("iOSMac KVO error.") | |
return | |
} | |
toolbarController.itemIdentifiers = ["com.pspdfkit.viewer.test"] | |
toolbarController.templateItems = [titleButton] | |
print("iOSMac extension initialized.") | |
} | |
} |
This file contains hidden or 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
#import <Foundation/Foundation.h> | |
@class NSString, UHASToolbarItem; | |
__attribute__((weak_import)) @interface _UIWindowToolbarItem : NSObject | |
@property(readonly, copy, nonatomic) NSString *label; | |
@property(readonly, copy, nonatomic) NSString *identifier; | |
- (id)initWithIdentifier:(id)arg1; | |
@end | |
__attribute__((weak_import)) @interface _UIWindowToolbarButtonItem : _UIWindowToolbarItem | |
@property(nonatomic) SEL action; // @synthesize action=_action; | |
@property(nonatomic) __weak id target; // @synthesize target=_target; | |
@property(copy, nonatomic) NSString *imageName; | |
@property(copy, nonatomic) NSString *label; | |
@property(nonatomic, getter=isEnabled) BOOL enabled; | |
@property(copy, nonatomic) NSString *title; | |
- (void)performAction; | |
- (id)_ourBackingItem; | |
- (id)initWithIdentifier:(id)arg1; | |
@end | |
@class NSArray, NSSet, NSString; | |
@protocol UHAToolbarInterface, UHAWindowInterface; | |
__attribute__((weak_import)) @interface _UIWindowToolbarController : NSObject | |
/*{ | |
id <UHAToolbarInterface> _toolbar; | |
id <UHAWindowInterface> _hostWindow; | |
NSArray *_itemIdentifiers; | |
NSString *_centeredItemIdentifier; | |
NSSet *_templateItems; | |
BOOL _hasExplicitToolbar; | |
}*/ | |
+ (id)sharedWindowToolbarController; | |
@property(copy, nonatomic) NSSet *templateItems; // @synthesize templateItems=_templateItems; | |
@property(copy, nonatomic) NSString *centeredItemIdentifier; // @synthesize centeredItemIdentifier=_centeredItemIdentifier; | |
@property(copy, nonatomic) NSArray *itemIdentifiers; // @synthesize itemIdentifiers=_itemIdentifiers; | |
- (void)_refreshToolbar; | |
@property(nonatomic) BOOL autoHidesToolbarInFullScreen; | |
- (id)_toolbarCreatingIfNeeded:(BOOL)arg1; | |
- (BOOL)_hasExplicitToolbar; | |
- (BOOL)_wantsToolbar; | |
- (void)updateForMainWindow:(id)arg1; | |
- (void)updateForMainHostWindowDidChangeNotification:(id)arg1; | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment