react-native-navigation的迁移库

RNNTabBarController.m 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #import "RNNTabBarController.h"
  2. #import "RNNRootViewController.h"
  3. #define kTabBarHiddenDuration 0.3
  4. @implementation RNNTabBarController
  5. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  6. return self.selectedViewController.supportedInterfaceOrientations;
  7. }
  8. - (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated {
  9. CGRect frame = self.tabBar.frame;
  10. CGFloat height = frame.size.height;
  11. CGFloat offsetY = (hidden ? self.view.frame.size.height : self.view.frame.size.height-height);
  12. frame.origin.y = offsetY;
  13. NSTimeInterval duration = animated ? kTabBarHiddenDuration : 0.0;
  14. [UIView animateWithDuration:duration animations:^{
  15. self.tabBar.frame = frame;
  16. }];
  17. }
  18. - (void)setSelectedIndexByContainerID:(NSString *)containerID {
  19. for (id child in self.childViewControllers) {
  20. RNNRootViewController* vc = child;
  21. if ([child isKindOfClass:[UINavigationController class]]) {
  22. vc = ((UINavigationController *)child).childViewControllers.firstObject;
  23. }
  24. if ([vc.containerId isEqualToString:containerID]) {
  25. [self setSelectedIndex:[self.childViewControllers indexOfObject:child]];
  26. }
  27. }
  28. }
  29. - (BOOL)isCustomTransitioned {
  30. return NO;
  31. }
  32. @end