Skip to content

Instantly share code, notes, and snippets.

@ianb821
Created November 25, 2014 02:00
Show Gist options
  • Save ianb821/14b6d2337544a3e5394b to your computer and use it in GitHub Desktop.
Save ianb821/14b6d2337544a3e5394b to your computer and use it in GitHub Desktop.
Grabbing Screenshot on Lock
To get the background I use _UICreateScreenUIImage();
Here's the declaration:
OBJC_EXTERN UIImage *_UICreateScreenUIImage(void) NS_RETURNS_RETAINED;
Specifically I hook SBBackLightController. Here is the bare bones of what I use:
%hook SBBacklightController
- (void)animateBacklightToFactor:(CGFloat)factor duration:(double)duration source:(int)source completion:(void (^)(void))completion {
if (factor < 0.1) {
UIImage *currentBackground = _UICreateScreenUIImage();
// Do whatever with currentBackground
}
%orig;
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment