Search code examples
iphoneuiviewuianimation

trying to slide a new UIView out from behind a UIButton ising UIAnimation


I'm attempting to push a button menu (a UIView containing UIButtons) out from behind a main UIButton

I've included an link to an image to give a better idea of what I'm getting at (the blue part containing the buttons slides out from behind the main button when the main button is pressed) -

http://imageshack.us/photo/my-images/27/screenshot20111027at419.png/

I created my UIView & placed my buttons on it & it animates without any problems. My plan was to place the buttons "off screen" (in relation to the coordinate system of my UIView) and then animate it so that the UIView slides into place (like a chest of drawers, the UIView is completely hidden initially)

However the buttons appear overlayed on the original UIButton which isn't what I wanted ;)

Any suggestions?, is there any way of hiding a UIView in certain parts of the main view?

Sorry for the long-windedness of my Question but I'm new to this :) Any help is much appreciated!

T*


Solution

  • @Octave1

    I am unable to comment on your question, but think it would help if you mocked up an image of what is happening vs what you want to see.

    Alternatively, some of your code would help us solve the problem.

    You can hide the view that you want don't want to see while animating the menu into place. Here is an example(Sorry if I got your views mixed up)

    /*
     assume buttonMenu is defined
     assume showMenuButton is defined
     assume menuEndFrame is defined 
    */
    [UIView beginAnimations:@"ButtonMenu" context:nil];
    
    [UIView setAnimationDuration:0.25];
    
    buttonMenu.frame = menuEndFrame
    showMenuButton.alpha = 0.0
    
    [UIView commitAnimations];
    

    If this isn't the issue and your view hierarchy is the issue, then you can use these 2 methods to help with the layering

    - (void)bringSubviewToFront:(UIView *)view
    
    - (void)sendSubviewToBack:(UIView *)view