Skip to content

Commit

Permalink
Merge pull request #25 from Ashton-W/bug/underStatusBar#23
Browse files Browse the repository at this point in the history
When using underStatusBar draw statusBarView with only navigationBar. Fixes #23
  • Loading branch information
cruffenach committed Mar 9, 2014
2 parents 4793ff3 + c6f8c80 commit 902d07b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions CRToast/CRToast.m
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,19 @@ - (CGRect)notificationViewAnimationFrame2 {

- (UIView*)statusBarView {
UIView *statusBarView = [[UIView alloc] initWithFrame:self.statusBarViewAnimationFrame1];
[statusBarView addSubview:[[UIScreen mainScreen] snapshotViewAfterScreenUpdates:YES]];
if ([self underStatusBar]) {
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIGraphicsBeginImageContextWithOptions(window.frame.size, NO, 0);
CGRect rect = CGRectMake(0, 0, window.frame.size.width, window.frame.size.height);
[window drawViewHierarchyInRect:rect afterScreenUpdates:YES];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *imageView = [[UIImageView alloc] initWithImage:screenshot];
[statusBarView addSubview:imageView];
}
else {
[statusBarView addSubview:[[UIScreen mainScreen] snapshotViewAfterScreenUpdates:YES]];
}
statusBarView.clipsToBounds = YES;
return statusBarView;
}
Expand Down Expand Up @@ -786,7 +798,6 @@ - (void)displayNotification:(CRToast*)notification {
statusBarView.frame = _notificationWindow.rootViewController.view.bounds;
[_notificationWindow.rootViewController.view addSubview:statusBarView];
statusBarView.hidden = notification.presentationType == CRToastPresentationTypeCover;
if (notification.underStatusBar) statusBarView.hidden = YES;

UIView *notificationView = notification.notificationView;
notificationView.frame = notification.notificationViewAnimationFrame1;
Expand Down

0 comments on commit 902d07b

Please sign in to comment.