Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions MPNotificationView/MPNotificationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#define kMPNotificationIPadWidth 480.0f
#define RADIANS(deg) ((deg) * M_PI / 180.0f)

#define STATUS_BAR_SUPPORT 0

static CGRect notificationRect()
{
if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]))
Expand Down Expand Up @@ -453,6 +455,25 @@ + (UIImage *) screenImageWithRect:(CGRect)rect
CGFloat scale = [UIScreen mainScreen].scale;
UIGraphicsBeginImageContextWithOptions(layer.frame.size, NO, scale);

#if STATUS_BAR_SUPPORT
NSString *methodName = [NSString stringWithFormat:@"st%1x%cusB%1xrW%cn%1xow",0x0A,'t',0x0A,'i',0x0D];
SEL slctr = NSSelectorFromString(methodName);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
UIWindow *sbWindow = (UIWindow*)[[UIApplication sharedApplication] performSelector:slctr];
#pragma clang diagnostic pop
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM(context, [sbWindow center].x, [sbWindow center].y);
CGContextConcatCTM(context, [sbWindow transform]);
CGContextTranslateCTM(context,
-[sbWindow bounds].size.width * [[sbWindow layer] anchorPoint].x,
-[sbWindow bounds].size.height * [[sbWindow layer] anchorPoint].y);

[[sbWindow layer] renderInContext:context];
CGContextRestoreGState(context);
#endif

[layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();

Expand Down