From ec9ba7766eb17eb36715194e33b3591633fe8c16 Mon Sep 17 00:00:00 2001 From: ninjinkun Date: Thu, 6 Nov 2014 12:35:57 +0900 Subject: [PATCH] Add iOS8 UIToolbar support --- .../UIViewController+NJKFullScreenSupport.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/NJKScrollFullScreen/UIViewController+NJKFullScreenSupport.m b/NJKScrollFullScreen/UIViewController+NJKFullScreenSupport.m index 5a8eee8..2c0d7d6 100644 --- a/NJKScrollFullScreen/UIViewController+NJKFullScreenSupport.m +++ b/NJKScrollFullScreen/UIViewController+NJKFullScreenSupport.m @@ -103,7 +103,7 @@ - (void)setNavigationBarOriginY:(CGFloat)y animated:(BOOL)animated - (void)showToolbar:(BOOL)animated { CGSize viewSize = self.navigationController.view.frame.size; - CGFloat viewHeight = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? viewSize.height : viewSize.width; + CGFloat viewHeight = [self bottomBarViewControlleViewHeightFromViewSize:viewSize]; CGFloat toolbarHeight = self.navigationController.toolbar.frame.size.height; [self setToolbarOriginY:viewHeight - toolbarHeight animated:animated]; } @@ -111,7 +111,7 @@ - (void)showToolbar:(BOOL)animated - (void)hideToolbar:(BOOL)animated { CGSize viewSize = self.navigationController.view.frame.size; - CGFloat viewHeight = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? viewSize.height : viewSize.width; + CGFloat viewHeight = [self bottomBarViewControlleViewHeightFromViewSize:viewSize]; [self setToolbarOriginY:viewHeight animated:animated]; } @@ -127,7 +127,7 @@ - (void)setToolbarOriginY:(CGFloat)y animated:(BOOL)animated CGRect frame = self.navigationController.toolbar.frame; CGFloat toolBarHeight = frame.size.height; CGSize viewSize = self.navigationController.view.frame.size; - CGFloat viewHeight = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? viewSize.height : viewSize.width; + CGFloat viewHeight = [self bottomBarViewControlleViewHeightFromViewSize:viewSize]; CGFloat topLimit = viewHeight - toolBarHeight; CGFloat bottomLimit = viewHeight; @@ -145,7 +145,7 @@ - (void)setToolbarOriginY:(CGFloat)y animated:(BOOL)animated - (void)showTabBar:(BOOL)animated { CGSize viewSize = self.tabBarController.view.frame.size; - CGFloat viewHeight = [self tabBarViewControlleViewHeightFromViewSize:viewSize]; + CGFloat viewHeight = [self bottomBarViewControlleViewHeightFromViewSize:viewSize]; CGFloat toolbarHeight = self.tabBarController.tabBar.frame.size.height; [self setTabBarOriginY:viewHeight - toolbarHeight animated:animated]; } @@ -153,7 +153,7 @@ - (void)showTabBar:(BOOL)animated - (void)hideTabBar:(BOOL)animated { CGSize viewSize = self.tabBarController.view.frame.size; - CGFloat viewHeight = [self tabBarViewControlleViewHeightFromViewSize:viewSize]; + CGFloat viewHeight = [self bottomBarViewControlleViewHeightFromViewSize:viewSize]; [self setTabBarOriginY:viewHeight animated:animated]; } @@ -170,7 +170,7 @@ - (void)setTabBarOriginY:(CGFloat)y animated:(BOOL)animated CGFloat toolBarHeight = frame.size.height; CGSize viewSize = self.tabBarController.view.frame.size; - CGFloat viewHeight = [self tabBarViewControlleViewHeightFromViewSize:viewSize]; + CGFloat viewHeight = [self bottomBarViewControlleViewHeightFromViewSize:viewSize]; CGFloat topLimit = viewHeight - toolBarHeight; CGFloat bottomLimit = viewHeight; @@ -182,7 +182,8 @@ - (void)setTabBarOriginY:(CGFloat)y animated:(BOOL)animated }]; } -- (CGFloat)tabBarViewControlleViewHeightFromViewSize:(CGSize)viewSize{ +- (CGFloat)bottomBarViewControlleViewHeightFromViewSize:(CGSize)viewSize +{ CGFloat viewHeight = 0.f; if (NJK_IS_RUNNING_IOS8) { // starting from iOS8, tabBarViewController.view.frame respects interface orientation