RQTabBarController.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // RQTabBarController.m
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/14.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import "RQTabBarController.h"
  9. #import "RQTabBar.h"
  10. @interface RQTabBarController ()
  11. /// tabBarController
  12. @property (nonatomic, strong, readwrite) QMUITabBarViewController *tabBarController;
  13. @end
  14. @implementation RQTabBarController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. self.tabBarController = [[QMUITabBarViewController alloc] init];
  18. /// 添加子控制器
  19. [self.view addSubview:self.tabBarController.view];
  20. [self addChildViewController:self.tabBarController];
  21. [self.tabBarController didMoveToParentViewController:self];
  22. // kvc替换系统的tabBar
  23. RQTabBar *tabbar = [[RQTabBar alloc] init];
  24. //kvc实质是修改了系统的_tabBar
  25. [self.tabBarController setValue:tabbar forKeyPath:@"tabBar"];
  26. }
  27. #pragma mark - Ovveride
  28. - (BOOL)shouldAutorotate {
  29. return self.tabBarController.selectedViewController.shouldAutorotate;
  30. }
  31. - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  32. return self.tabBarController.selectedViewController.supportedInterfaceOrientations;
  33. }
  34. - (UIStatusBarStyle)preferredStatusBarStyle {
  35. return self.tabBarController.selectedViewController.preferredStatusBarStyle;
  36. }
  37. - (BOOL)prefersStatusBarHidden{
  38. return self.tabBarController.selectedViewController.prefersStatusBarHidden;
  39. }
  40. @end