views:

456

answers:

1

iPhone / Objective-C

On my view a little "hover" view appears after a user clicks on a button on the main view. When the user clicks this subview I want the subview to FlipFromRight to another view (same size). The main view underneath should stay.

viewHot and viewCold are the subviews viewMain is the main one.

Is this possible?

+3  A: 

Create another empty view in viewMain called viewHover and position it where you want the hover views to show. Then in IB add either viewHot or viewCold (not both) as a subview of viewHover.

Then call a method like this to flip the views:

-(void)flipViews
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];  
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:viewHover cache:YES];

    if ([viewHot superview])
    {
        [viewHot removeFromSuperview];
        [viewHover addSubview:viewCold];
        [viewHover sendSubviewToBack:viewHot];
    }
    else
    {
        [viewCold removeFromSuperview];
        [viewHover addSubview:viewHot];
        [viewHover sendSubviewToBack:viewCold];
    }

    [UIView commitAnimations];
}
DyingCactus
This is excellent, thank you so much
BahaiResearch.com
This code helped me in presenting a small modal view.Thank you.
Sasho