From 9eb9ca0041b9fa463e2dc1404e233907b35f400c Mon Sep 17 00:00:00 2001 From: Jochen Pfeiffer Date: Mon, 13 Apr 2015 13:30:10 +0200 Subject: [PATCH 1/2] fixed an issue with custom container view controllers (child view controller origin.y is not 0) --- CSNotificationView/CSNotificationView.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CSNotificationView/CSNotificationView.m b/CSNotificationView/CSNotificationView.m index 4f4fbb0..560d736 100644 --- a/CSNotificationView/CSNotificationView.m +++ b/CSNotificationView/CSNotificationView.m @@ -383,6 +383,10 @@ - (void)dismissWithStyle:(CSNotificationViewStyle)style message:(NSString *)mess - (CGFloat)topLayoutGuideLengthCalculation { CGFloat top = MIN([UIApplication sharedApplication].statusBarFrame.size.height, [UIApplication sharedApplication].statusBarFrame.size.width); + + UIView *view = self.parentNavigationController.view ?: self.parentViewController.view; + CGPoint origin = [view.superview convertPoint:view.frame.origin toView:[UIApplication sharedApplication].keyWindow.rootViewController.view]; + top -= origin.y; if (self.parentNavigationController && !self.parentNavigationController.navigationBarHidden) { From 38f8e3d02e32b4e9891499652f9bec84654d30da Mon Sep 17 00:00:00 2001 From: Jochen Pfeiffer Date: Tue, 14 Apr 2015 11:26:31 +0200 Subject: [PATCH 2/2] improved code readability --- CSNotificationView/CSNotificationView.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CSNotificationView/CSNotificationView.m b/CSNotificationView/CSNotificationView.m index 560d736..a846950 100644 --- a/CSNotificationView/CSNotificationView.m +++ b/CSNotificationView/CSNotificationView.m @@ -382,11 +382,15 @@ - (void)dismissWithStyle:(CSNotificationViewStyle)style message:(NSString *)mess //Workaround as there is a bug: sometimes, when accessing topLayoutGuide, it will render contentSize of UITableViewControllers to be {0, 0} - (CGFloat)topLayoutGuideLengthCalculation { - CGFloat top = MIN([UIApplication sharedApplication].statusBarFrame.size.height, [UIApplication sharedApplication].statusBarFrame.size.width); + CGFloat top = 0; UIView *view = self.parentNavigationController.view ?: self.parentViewController.view; - CGPoint origin = [view.superview convertPoint:view.frame.origin toView:[UIApplication sharedApplication].keyWindow.rootViewController.view]; - top -= origin.y; + CGPoint originInWindow = [view.superview convertPoint:view.frame.origin toView:[UIApplication sharedApplication].keyWindow.rootViewController.view]; + CGFloat statusBarHeight = MIN([UIApplication sharedApplication].statusBarFrame.size.height, [UIApplication sharedApplication].statusBarFrame.size.width); + + if (originInWindow.y < statusBarHeight) { + top += statusBarHeight - originInWindow.y; + } if (self.parentNavigationController && !self.parentNavigationController.navigationBarHidden) {