iPhone Pushing View Controller in a left direction

前端 未结 6 1593
耶瑟儿~
耶瑟儿~ 2020-12-05 12:07

I have an app that has a centre view with two views off to each side of it. I want to have two navigation bar buttons, left and right which push a new navigation controller

6条回答
  •  鱼传尺愫
    2020-12-05 12:44

    to what Reed Olsen said: you must only hook up one button, that starts the slide up to the same method and add a BOOL that tracks if the view is shown or not. all you need to do is set the origin properly.

    - (IBAction)slideMenuView 
    {
      CGRect inFrame = [self.view frame];
      CGRect outFrame = self.view.frame;
    
      if (self.viewisHidden) {
        outFrame.origin.x += inFrame.size.width-50;
        self.viewisHidden = NO;
      } else {
        outFrame.origin.x -= inFrame.size.width-50;
        self.viewisHidden = YES;
      }
      [UIView beginAnimations:nil context:nil];
      [UIView setAnimationDuration:0.5];
      [self.menuView setFrame:inFrame];
      [self.view setFrame:outFrame];
      [UIView commitAnimations];
    }
    

提交回复
热议问题