Skip to content

Commit

Permalink
Add iOS8 UIToolbar support
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjinkun committed Nov 6, 2014
1 parent 793cbe9 commit ec9ba77
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions NJKScrollFullScreen/UIViewController+NJKFullScreenSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ - (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];
}

- (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];
}

Expand All @@ -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;
Expand All @@ -145,15 +145,15 @@ - (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];
}

- (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];
}

Expand All @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit ec9ba77

Please sign in to comment.