From a3e56458dd79bcbf5b90f8724c46bef8bce1d0f1 Mon Sep 17 00:00:00 2001 From: Joey Lorich Date: Mon, 2 Mar 2015 12:59:37 -0500 Subject: [PATCH 1/2] Switch to using topLayoutGuid to determine vertical offset --- Pod/Classes/TSMessage.m | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/Pod/Classes/TSMessage.m b/Pod/Classes/TSMessage.m index 5c4d530b..5e9ae13c 100755 --- a/Pod/Classes/TSMessage.m +++ b/Pod/Classes/TSMessage.m @@ -188,19 +188,7 @@ - (void)fadeInCurrentNotification notificationActive = YES; TSMessageView *currentView = [self.messages objectAtIndex:0]; - - __block CGFloat verticalOffset = 0.0f; - - void (^addStatusBarHeightToVerticalOffset)() = ^void() { - - if (currentView.messagePosition == TSMessageNotificationPositionNavBarOverlay){ - return; - } - - CGSize statusBarSize = [UIApplication sharedApplication].statusBarFrame.size; - verticalOffset += MIN(statusBarSize.width, statusBarSize.height); - }; - + if ([currentView.viewController isKindOfClass:[UINavigationController class]] || [currentView.viewController.parentViewController isKindOfClass:[UINavigationController class]]) { UINavigationController *currentNavigationController; @@ -218,25 +206,15 @@ - (void)fadeInCurrentNotification { [currentNavigationController.view insertSubview:currentView belowSubview:[currentNavigationController navigationBar]]; - verticalOffset = [currentNavigationController navigationBar].bounds.size.height; - if ([TSMessage iOS7StyleEnabled] || isViewIsUnderStatusBar) { - addStatusBarHeightToVerticalOffset(); - } } else { [currentView.viewController.view addSubview:currentView]; - if ([TSMessage iOS7StyleEnabled] || isViewIsUnderStatusBar) { - addStatusBarHeightToVerticalOffset(); - } } } else { [currentView.viewController.view addSubview:currentView]; - if ([TSMessage iOS7StyleEnabled]) { - addStatusBarHeightToVerticalOffset(); - } } CGPoint toPoint; @@ -248,9 +226,9 @@ - (void)fadeInCurrentNotification { navigationbarBottomOfViewController = [self.delegate messageLocationOfMessageView:currentView]; } - + CGFloat topLayoutGuideLength = [[currentView.viewController topLayoutGuide] length]; toPoint = CGPointMake(currentView.center.x, - navigationbarBottomOfViewController + verticalOffset + CGRectGetHeight(currentView.frame) / 2.0); + navigationbarBottomOfViewController + topLayoutGuideLength + CGRectGetHeight(currentView.frame) / 2.0); } else { From a55f64461f868219ddc28e4e12be8e103711f24e Mon Sep 17 00:00:00 2001 From: Joey Lorich Date: Mon, 2 Mar 2015 15:02:46 -0500 Subject: [PATCH 2/2] Add a fix for UINavigationControllers --- Pod/Classes/TSMessage.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/TSMessage.m b/Pod/Classes/TSMessage.m index 5e9ae13c..a1bee2b8 100755 --- a/Pod/Classes/TSMessage.m +++ b/Pod/Classes/TSMessage.m @@ -226,9 +226,15 @@ - (void)fadeInCurrentNotification { navigationbarBottomOfViewController = [self.delegate messageLocationOfMessageView:currentView]; } - CGFloat topLayoutGuideLength = [[currentView.viewController topLayoutGuide] length]; + + CGFloat verticalOffset = [[currentView.viewController topLayoutGuide] length]; + + if ([currentView.viewController isKindOfClass:[UINavigationController class]]) { + verticalOffset += ((UINavigationController *)currentView.viewController).toolbar.frame.size.height; + } + toPoint = CGPointMake(currentView.center.x, - navigationbarBottomOfViewController + topLayoutGuideLength + CGRectGetHeight(currentView.frame) / 2.0); + navigationbarBottomOfViewController + verticalOffset + CGRectGetHeight(currentView.frame) / 2.0); } else {