cocoa touch - iOS Slide an UIView (Menu) from a side in another View -



cocoa touch - iOS Slide an UIView (Menu) from a side in another View -

i want slide in menu side in view after buttonclick event. after buttonclick menu should slided out big view...

i experimented catransition can't solve problem...

catransition *animation = [catransition animation]; [animation setduration:1]; [animation settype:kcatransitionpush]; [animation setsubtype:kcatransitionfrombottom]; [animation settimingfunction:[camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]] ; [[menuview layer] addanimation:animation forkey:@"@asdf"]; [menuview setcenter:cgpointmake([menuview center].x, [menuview center].y + 450)];

it work bit, did not understand why.. :-/

if want implement 1 way can go create custom view , add together button click event button in view controller.

also create boolean variable identify whether custom view visible or not.

on click, if menu view not visible, this:

-(void)viewdidload { ... // --------------------------------------------- // create custom menu view off screen // --------------------------------------------- menuview = [[menuview alloc] initwithframe:cgrectmake(-320, 0, 320, 480)]; menuview.alpha = 0; // hide doesn't show @ start, show when slide in [self.view addsubview:menuview]; ... } -(void)togglemenu { if(menuisvisible) { menuisvisible = no; [self hidemenu]; } else { menuisvisible = yes; [self showmenu]; } } -(void)hidemenu { [uiview animatewithduration:0.5 animations:^{ // note cgaffinetransforms doesn't utilize coordinates, utilize offset // offset of (0,0) bring menuview coordinate // when first instantiated, in our case, (-320, 0). menuview.transform = cgaffinetransformmaketranslation(0,0); } completion:^{ // hide menu menuview.alpha = 0; }]; } -(void)showmenu { // show menu menuview.alpha = 1; [uiview animatewithduration:0.5 animations:^{ // note cgaffinetransforms doesn't utilize coordinates, utilize offset // offset of (320,0) coordinate (-320,0) slide // menuview out view menuview.transform = cgaffinetransformmaketranslation(320,0); }]; }

ios cocoa-touch uiview ios4 core-animation

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -