Search code examples
iphoneiosuiviewcontrolleruitabbarcontroller

Tabbar Controller with swipe effect


I'm trying to do a Tabbar Controller like below effect:

image

By swiping an viewcontroller will redirect to next tab. How can we achieve this in iOS? Is there any other controls to do like this?


Solution

  • Just add UISwipeGestureRecognizer to your tabBarView controller and change your tabBar index after swipe.

    swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self 
                                                                          action:@selector(swipeMethod:)];
    swipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight | UISwipeGestureRecognizerDirectionLeft; 
    [self addGestureRecognizer:swipeRecognizer];  
    

    And my method to handle swipe is :

    -(void)swipeMethod: (UISwipeGestureRecognizer *) sender
    {
        NSLog(@"Swipe!");   
    } 
    

    EDIT
    Or you can use UIScrollView with paging enable and UIView to display your data.

    Here is the tutorial you are looking for Tabbar Controller with swipte effect