Pramod Tapaniya
Pramod Tapaniya

Reputation: 1266

Implement SWRevealViewController on only one UITabBarItem

I implement SWRevealViewController with UITabbarController via storyboard. I want to display SWRevealViewController in first UITabBarItem only, in other UITabBarItem i don't want to open SWRevealViewController, that done completely. But problem is position of UITabBar is not change like viewcontroller while SWRevealViewController is appear.

Please help me.

enter image description here

Storyboard structure enter image description here

Upvotes: 8

Views: 396

Answers (1)

Pramod Tapaniya
Pramod Tapaniya

Reputation: 1266

I solve the problem by change position of UITabbar manually using SWRevealViewController delegate method. Put this code in 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);
}

Upvotes: 2

Related Questions