You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
let ToolbarPlatformDelegate: AnyClass = objc_lookUpClass("_TtC7SwiftUI23ToolbarPlatformDelegate")!
let method = class_getInstanceMethod(ToolbarPlatformDelegate, #selector(NSToolbarDelegate.toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:)))!
oldIMP = method_getImplementation(method)
let newIMPFunc: @convention(c) (AnyObject, Selector, NSToolbar, NSToolbarItem.Identifier, ObjCBool) -> NSToolbarItem? = { `self`, _cmd, toolbar, itemIdentifier, flag in
let oldIMPFunc = unsafeBitCast(oldIMP, to: (@convention(c) (AnyObject, Selector, NSToolbar, NSToolbarItem.Identifier, ObjCBool) -> NSToolbarItem?).self)
let item = oldIMPFunc(self, _cmd, toolbar, itemIdentifier, flag)
if let item, itemIdentifier.rawValue == "com.apple.SwiftUI.navigationStack.back" {
// SwiftUI.SwiftUISegmentedControl
let control = item.view!.subviews.first!.subviews.first! as! NSSegmentedControl
control.sizeToFit()
item.view!.setFrameSize(control.bounds.size)
}
return item
}
method_setImplementation(method, unsafeBitCast(newIMPFunc, to: IMP.self))