Skip to content

Instantly share code, notes, and snippets.

@twodayslate
Last active September 11, 2021 23:33
Show Gist options
  • Save twodayslate/ca1599d669df2e9842e1f1e257b236f2 to your computer and use it in GitHub Desktop.
Save twodayslate/ca1599d669df2e9842e1f1e257b236f2 to your computer and use it in GitHub Desktop.
Move the DisclosureGroup indicator in SwiftUI
// You'll need the following Swift Packages
// - https://github.com/siteline/SwiftUI-Introspect
// - https://github.com/steipete/InterposeKit
// DisclosureGroup(...)
.introspectViewController { controller in
func findViews(_ view: UIView, depth: Int = 0) {
for sub in view.subviews {
findViews(sub, depth: depth + 1)
}
if ((view.superview?.classForCoder.description().contains("PlatformGroupContainer")) != nil), ((view.superview?.superview?.classForCoder.description().contains("HostingScrollView")) != nil), view.subviews.count == 0, view.layer.classForCoder.description() == "SwiftUI.ImageLayer" {
let _ = try? view.hook(#selector(setter: UIView.transform), methodSignature: (@convention(c) (AnyObject, Selector, CGAffineTransform) -> Void).self, hookSignature: (@convention(block) (AnyObject, CGAffineTransform) -> Void).self, { store in { `self`, arg in
var new = arg
new.tx = -8
store.original(`self`, store.selector, new)
}
})
view.transform = .init(translationX: -8, y: 0)
}
}
findViews(controller.view)
for child in controller.children {
findViews(child.view)
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment