仅在一个 UITabBarItem 上实施 SWRevealViewController

Implement SWRevealViewController on only one UITabBarItem

我通过故事板使用 UITabbarController 实现 SWRevealViewController。 我只想在第一个 UITabBarItem 中显示 SWRevealViewController,在其他 UITabBarItem 中我不想打开 SWRevealViewController,这完全完成了。 但问题是 UITabBar 的位置没有像 viewcontroller 那样改变,而 SWRevealViewController 出现了。

请帮帮我

故事板结构

我通过使用 SWRevealViewController 委托方法手动更改 UITabbar 的位置来解决问题。 把这个代码放在 MenuViewController.

MenuViewController.m

- (void) viewDidLoad {
    [super viewDidLoad];

    UITabBarController *tbc = (UITabBarController *)[[[[UIApplication sharedApplication]delegate]window]rootViewController];
    self.tabBar = tbc.tabBar;

    _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height);
    self.revealViewController.delegate = self;
}

- (void) revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position {
    if (position == FrontViewPositionRight) {
        _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height);
    }
    else {
        _tabBar.frame = CGRectMake(0, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height);
    }
}

- (void)revealController:(SWRevealViewController *)revealController panGestureMovedToLocation:(CGFloat)location progress:(CGFloat)progress overProgress:(CGFloat)overProgress {
    _tabBar.frame = CGRectMake(self.revealViewController.rearViewRevealWidth * progress, _tabBar.frame.origin.y, _tabBar.frame.size.width, _tabBar.frame.size.height);
}