Skip to content

Commit

Permalink
Added iOS8 support for tabbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
TonnyXu committed Oct 1, 2014
1 parent 718073c commit 45ce6c1
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions NJKScrollFullScreen/UIViewController+NJKFullScreenSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,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 tabBarViewControlleViewHeightFrom: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 tabBarViewControlleViewHeightFrom:viewSize];
[self setTabBarOriginY:viewHeight animated:animated];
}

Expand All @@ -163,7 +163,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 tabBarViewControlleViewHeightFrom:viewSize];

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

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

- (CGFloat)tabBarViewControlleViewHeightFrom:(CGSize)viewSize{
CGFloat viewHeight = 0.f;
NSString *osMajorVersionStr = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."][0];
NSInteger osMajorVersion = [osMajorVersionStr integerValue];
if (osMajorVersion >= 8) {
// 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 45ce6c1

Please sign in to comment.