0

EDIT: Wow, what an idiot I am. To make it very easy to understand, I wanted to explain the facebook native app sort of functionality. Where you touch the top right and top left, the middle portion goes in to left or right, revealing a side bar menu

I have a phonegap app wherein on the top right corner, there is a button. Take the below code as reference.

Portion of HTML:

<body>
<div id="header"><!--Button goes here--></div>
<div id="menu">
    <ul>
        <li> Option 1</li>
        <li> Option 2</li>
    </ul> 
</div>
<div id="page">
     Some contents in the page.
</div>
</body>

Javascript:
var move,x=0; //global vars

function buttonTouched() { //code for button ontouchstart event
    move = $("#menu").css('width');
    if(x==0) {
        $("#menu").animate({'left':'-='+move},'250');
        $("#page").animate({'left':'-='+move},'250');
        x=1;
    }
    else if(x==1) {
        $("#menu").animate({'left':'+='+move},'250');
        $("#page").animate({'left':'+='+move},'250');
        x=0;
    }
}

When you touch the button, "menu" div slides left (using jquery animate) and a portion of the "page" div goes to the left. How do I replicate this effect in native app using objective C code with animate effect?

Thanks

thandasoru
  • 1,558
  • 2
  • 15
  • 41
  • Requesting mods to close the question, as I've tried to ask the same question as seen here http://stackoverflow.com/questions/7989020/whats-the-best-way-to-develop-a-sideswipe-menu-like-the-one-in-facebooks-new-i – thandasoru Feb 21 '13 at 08:42

1 Answers1

1

Take a look at the UIView animateWithDuration class methods.

Lets say your menu is just a UIView named menuView and is placed offscreen in your viewcontroller. Then you can do something like this:

[UIView animateWithDuration:0.6
                          delay:0.0
                        options:UIViewAnimationCurveEaseOut
                     animations:^{
                         CGRect oldFrame = self.view.frame;
                         xOffset = menuView.frame.width;
                         self.view.frame = CGRectOffset(oldFrame, xOffset, 0);
                     }];
peko
  • 11,267
  • 4
  • 33
  • 48
  • Ah cool, I will try this and will let you know. Thanks for taking time and answering! – thandasoru Feb 21 '13 at 08:39
  • It works, but the buttons in the other view are not working, even though I hooked up the Touch up Inside to corresponding IBActions. – thandasoru Mar 02 '13 at 15:17