Sliding menu that keeps background behind (Xcode 4.3)

I have been searching for a way to make a menu come 80 pixels down from the top of the screen and have the screen slide down with it (80 pixels) when the user swipes his finger from top to bottom (and reverse it when they swipe top to bottom to send it back up). How should i go about doing that? Anything helps. Thank you!

Answers


  1. Create a UISwipeGestureRecognizer and add it to the view you want it to appear on:

    UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe:)];
    [swipeGesture setDirection:UISwipeGestureRecognizerDirectionDown];
    [self.view addGestureRecognizer:swipeGesture];
    
  2. Create an instance variable that will hold your menu view and add it to the view OUTSIDE of the screen (note -80 y-coordinate):

    menuView = [[UIView alloc] initWithFrame:CGRectMake(0, -80, 320, 80)];
    //add whatever controls you need to the menu view, or load it from a nib
    [self.view addSubview:menuView];
    
  3. Define a method that will slide the menu onto the view when down swipe is detected:

    -(void)swipe:(UISwipeGestureRecognizer*)sender {
            [UIView animateWithDuration:0.5 animations:^{
                [menuView setFrame:CGRectMake(0, 0, 320, 80)];
        }];
    }
    

If you want the screen to slide down with it or anything else you might like to happen, add additional actions to the animation block.

To remove the view with the upward slide, you can create another UISwipeGestureRecognizer, but with UISwipeGestureRecognizerDirectionUp direction. Make another method that will do a reverse-slide of the menu.

Hope it helps.


Need Your Help

Cascade Save - StaleObjectStateException: Row was updated or deleted by another transaction

nhibernate nhibernate-mapping

Having an issue with updating the NHibernate version. Current version is 3.3.1.4000 and trying to update to 4.

Differentiate between an empty cell and a cell which contains a formula

excel vbscript

Is there a way in VBScript to check whether a cell is perceived to be empty (looks empty) but has a formula within it? Or rather how to check that the cell contains no other content but a formula w...