Search code examples
iosiphoneobjective-cviewflipper

how do an android viewflipper but with iOS


i need to implement two different views, one for a map and the other for a list. And that i want is to switch the view to the other when we click on a button. I know how we can do with two different views that we hide, but i want that like with the viewflipper for android the views switched like one view which is split into two like this :

http://www.youtube.com/watch?v=SZTiJmclaRc

Thx.

ps: sorry for my english, i'm not very fluent in english.


Solution

  • You could use a CATransition to achieve this sort of effect quite easily. For example:

    CATransition *animation = [CATransition animation];
    animation.delegate = self;
    animation.duration = 0.3f;
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    animation.type = kCATransitionPush;
    animation.subtype = kCATransitionFromRight;
    [self.view.layer addAnimation:animation forKey:@"transition"];
    
    // swap out your views here - either add / remove subviews or show / hide subviews
    [self.view addSubview:otherView];
    

    When animating the other way, change the subtype to kCATransitionFromLeft.

    You'll also need to link to the QuartzCore framework, and import <QuartzCore/QuartzCore.h>