Skip to content

Commit

Permalink
Merge pull request #21 from TonnyXu/master
Browse files Browse the repository at this point in the history
Added iOS8 support for tabbar.
  • Loading branch information
ninjinkun committed Oct 16, 2014
2 parents 718073c + 6ecf3e4 commit 64a7ae2
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions NJKScrollFullScreen/UIViewController+NJKFullScreenSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
#define NJK_IS_RUNNING_IOS7 NO
#endif

#if __IPHONE_8_0 && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
#define NJK_IS_RUNNING_IOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#else
#define NJK_IS_RUNNING_IOS8 NO
#endif

#import "UIViewController+NJKFullScreenSupport.h"

#define kNearZero 0.000001f
Expand Down Expand Up @@ -139,15 +145,15 @@ - (void)setToolbarOriginY:(CGFloat)y animated:(BOOL)animated
- (void)showTabBar:(BOOL)animated
{
CGSize viewSize = self.tabBarController.view.frame.size;
CGFloat viewHeight = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? viewSize.height : viewSize.width;
CGFloat viewHeight = [self tabBarViewControlleViewHeightFromViewSize: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 = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? viewSize.height : viewSize.width;
CGFloat viewHeight = [self tabBarViewControlleViewHeightFromViewSize:viewSize];
[self setTabBarOriginY:viewHeight animated:animated];
}

Expand All @@ -163,7 +169,9 @@ - (void)setTabBarOriginY:(CGFloat)y animated:(BOOL)animated
CGRect frame = self.tabBarController.tabBar.frame;
CGFloat toolBarHeight = frame.size.height;
CGSize viewSize = self.tabBarController.view.frame.size;
CGFloat viewHeight = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? viewSize.height : viewSize.width;

CGFloat viewHeight = [self tabBarViewControlleViewHeightFromViewSize:viewSize];

CGFloat topLimit = viewHeight - toolBarHeight;
CGFloat bottomLimit = viewHeight;

Expand All @@ -174,4 +182,16 @@ - (void)setTabBarOriginY:(CGFloat)y animated:(BOOL)animated
}];
}

- (CGFloat)tabBarViewControlleViewHeightFromViewSize:(CGSize)viewSize{
CGFloat viewHeight = 0.f;
if (NJK_IS_RUNNING_IOS8) {
// starting from iOS8, tabBarViewController.view.frame respects interface orientation
viewHeight = viewSize.height;
} else {
viewHeight = UIInterfaceOrientationIsPortrait(self.interfaceOrientation) ? viewSize.height : viewSize.width;
}

return viewHeight;
}

@end

0 comments on commit 64a7ae2

Please sign in to comment.