react-native-navigation的迁移库

RNNTabBarController.m 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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)setSelectedIndexByComponentID:(NSString *)componentID {
  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.componentId isEqualToString:componentID]) {
  25. [self setSelectedIndex:[self.childViewControllers indexOfObject:child]];
  26. }
  27. }
  28. }
  29. - (BOOL)isCustomTransitioned {
  30. return NO;
  31. }
  32. - (NSString *)componentId {
  33. return ((UIViewController<RNNRootViewProtocol>*)self.selectedViewController).componentId;
  34. }
  35. @end