Skip to content

Instantly share code, notes, and snippets.

@NSExceptional
Last active May 1, 2018 02:40
Show Gist options
  • Save NSExceptional/435886a77568d1dca367ae4cfd40c8f9 to your computer and use it in GitHub Desktop.
Save NSExceptional/435886a77568d1dca367ae4cfd40c8f9 to your computer and use it in GitHub Desktop.
A tweak to enable 3D Touch on the home bar to go home
#import <objc/runtime.h>
#define simulateHomePress() [(SpringBoard *)[UIApplication sharedApplication] _simulateHomeButtonPress]
@interface SpringBoard : UIApplication
- (void)_simulateHomeButtonPress;
@end
static UITapGestureRecognizer *bounceTap = nil;
%subclass TBHomeBarTapGestureRecognizer : UITapGestureRecognizer
%new
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
UITouch *t = touches.allObjects.firstObject;
if (touches.count == 1 && t.force == t.maximumPossibleForce) {
if ([t.gestureRecognizers containsObject:(id)self]) {
simulateHomePress();
}
}
}
%end
%hook SBHomeGrabberRevealGesturesManager
- (id)init {
%orig;
bounceTap = [(id)self valueForKey:@"_bounceTapRecognizer"];
object_setClass(bounceTap, %c(TBHomeBarTapGestureRecognizer));
return self;
}
// Just hook this method to enable tap for home
// - (void)_tapRecognized:(UITapGestureRecognizer *)tap {
// if (tap == bounceTap) {
// simulateHomePress();
// } else {
// %orig;
// }
// }
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment