react-native-navigation的迁移库

BottomTabsAppearancePresenter.m 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #import "BottomTabsAppearancePresenter.h"
  2. #import "UIColor+RNNUtils.h"
  3. @implementation BottomTabsAppearancePresenter
  4. # pragma mark - public
  5. - (void)applyBackgroundColor:(UIColor *)backgroundColor translucent:(BOOL)translucent {
  6. if (translucent) [self setTabBarTranslucent:YES];
  7. else if (backgroundColor.isTransparent) [self setTabBarTransparentBackground];
  8. else if (backgroundColor) [self setTabBarBackgroundColor:backgroundColor];
  9. else [self setTabBarDefaultBackground];
  10. }
  11. - (void)setTabBarBackgroundColor:(UIColor *)backgroundColor {
  12. [self setTabBarOpaqueBackground];
  13. for (UIViewController* childViewController in self.tabBarController.childViewControllers)
  14. childViewController.tabBarItem.standardAppearance.backgroundColor = backgroundColor;
  15. }
  16. - (void)setTabBarTranslucent:(BOOL)translucent {
  17. if (translucent) [self setTabBarTranslucentBackground];
  18. else [self setTabBarOpaqueBackground];
  19. }
  20. # pragma mark - private
  21. - (void)setTabBarDefaultBackground {
  22. [self setTabBarOpaqueBackground];
  23. }
  24. - (void)setTabBarTranslucentBackground {
  25. for (UIViewController* childViewController in self.tabBarController.childViewControllers)
  26. [childViewController.tabBarItem.standardAppearance configureWithDefaultBackground];
  27. }
  28. - (void)setTabBarTransparentBackground {
  29. for (UIViewController* childViewController in self.tabBarController.childViewControllers)
  30. [childViewController.tabBarItem.standardAppearance configureWithTransparentBackground];
  31. }
  32. - (void)setTabBarOpaqueBackground {
  33. for (UIViewController* childViewController in self.tabBarController.childViewControllers)
  34. [childViewController.tabBarItem.standardAppearance configureWithOpaqueBackground];
  35. }
  36. @end