Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 469
Pramod Tapaniya Avatar asked Jan 18 '16 09:01

Pramod Tapaniya


1 Answers

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);
}
like image 200
Pramod Tapaniya Avatar answered Oct 22 '22 01:10

Pramod Tapaniya