title: Off by 20 pixels (y axis) when adding subview myNavigationController.view
body: <p>I have a navigation controller with a menu button. When the menu button is pressed, the current view (complete with its navigation bar) should slide to the right, and a menu should simultaneously and contiguously slide in from the left. The details are explained in the comments in the code, below.</p>
  
  <p>It works except in one regard. The current view (in this case, "Conversations"), when added back into the container view I implement, has to have its frame set to "y.min"=-20, or else there are 20 pixels above its navigation bar. However, when I set its y.min to -20, this shifts everything within its view up by 20 pixels. So when the menu button is pressed, everything in the current view suddenly jumps upwards by 20 pixels. </p>
  
  <p>I can't figure out why this is happening or how to correct this. It is also possible that there's an easier way to go about all of this, but I'm not aware of one.* (*I'm not interested in third-party files. I want to learn to do this myself.)</p>
  
  <p>Here is the code:</p>
  
  <pre><code>- (IBAction) showMenu:(id)sender
  {
  
  // get pointer to app delegate, which contains property for menu pointer
  AppDelegate *appDelegate = getAppDelegate;
  
  //create container view so that current view, along with its navigation bar, can be displayed alongside menu
  UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 548.0f)];
  [container setBackgroundColor:[UIColor blueColor]];
  
  //before presenting menu, create pointer for current view, to be used in completion routine
  UIView *presenter = self.navigationController.view;
  
  //present menu's VC. it is necessary to present its (table) VC, not just add its view, to retain the functionality of its cells
  [self presentViewController:appDelegate.menuVC animated:NO completion: ^{
  
      //obtain a pointer to the menu VC's view
      UIView *menuTemp = appDelegate.menuVC.view;
  
      //replace menu VC's view with the empty container view
      appDelegate.menuVC.view = container;
  
      //add the menu view to the container view and set its frame off screen
      [container addSubview:menuTemp];
      menuTemp.frame = CGRectMake(-260.0f, 0.0f, 260.0f, 548.0f);
  
      //add the the view that was displayed when the user pressed the menu button. set its frame to fill the screen as normal
      [appDelegate.menuVC.view addSubview:presenter];
      presenter.frame = CGRectMake(0.0f, 0.0f, 320.0f, 548.0f);
  
      //animate the 2 subviews that were just added; "PRESENTER"'S FRAME IS THE ISSUE
      [UIView animateWithDuration:25.3f delay:0.0f options:nil animations:^{
                           [menuTemp setFrame:CGRectMake(0.0f, 0.0f, 260.0f, 548.0f)];
                           [presenter setFrame:CGRectMake(260.0f, -20.0/* or 0 */f, 320.0f, 548.0f)];
                       } completion:nil];
  
  }];
  }
  </code></pre>
  
  <p>Here is an illustration of my two options (click for higher resolution):
  <a href="https://i.imgur.com/BdqMZP5.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/BdqMZP5.png" alt="visual"></a></p>
  
  <p>screen 1) The first screen shows the view before clicking the menu button. </p>
  
  <p>The next two screens show two possibilities as the menu transition animation begins.</p>
  
  <p>screen 2) This is what the transition looks like when I set presenter.frame.y.min to -20. As you can see, the button in the view has jumped up by 20 pixels.</p>
  
  <p>screen 3) This is what the transition looks like when I set presenter.frame.y.min to 0. As you can see, a bar 20 pixels tall is present at the top. The blue color indicates the container view.</p>