title: Restore default navigation bar appearance
body: <p>I'm making an iOS app for iPhone, and I'm using a navigation controller. At some point during the navigation, I'm adding a <code>UISegmentedControl</code> to a view controller, just under the navigation bar from the navigation controller. I'm inserting new background and shadow images in the navigation bar, to make the <code>UISegmentedControl</code> appear as part of the navigation bar. I do it like this:</p>
  
  <pre><code>    // nav bar color image
      let rect = CGRectMake(0, 0, view.frame.width, 0.5)          // Used in navBar, size dosn't matter
      UIGraphicsBeginImageContextWithOptions(rect.size, true, 0)
      barBackgroundColor.setFill()
      UIRectFill(rect)
      let navBarBackground = UIGraphicsGetImageFromCurrentImageContext()
      UIGraphicsEndImageContext()
  
      // setup navbar
      navigationController!.navigationBar.setBackgroundImage(navBarBackground, forBarMetrics: .Default)
      navigationController!.navigationBar.shadowImage = UIImage()
      navigationController!.navigationBar.tintColor = UIColor.blackColor()
      navigationController!.navigationBar.translucent = false
  </code></pre>
  
  <p>When I navigate away from that given view controller, the navigation bars background is still changed.</p>
  
  <p><strong>How can I restore the navigation bars appearance?</strong></p>
  
  <p>Or...</p>
  
  <p><strong>Is there another way embed the <code>UISegmentedControl</code> into an expanded navigation bar?</strong></p>
  
  <p>Image of navigation bar with custom background and Segmented Control below:
  <a href="https://i.stack.imgur.com/wme5L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wme5L.png" alt="Navbar with custom background. plus segment control below"></a></p>
  
  <p>When navigating back, the navigation bar cuntinues to be custom:
  <a href="https://i.stack.imgur.com/S6E10.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S6E10.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>In a view controller before i change the background images, i try to safe the standart image:</p>
  
  <pre><code>override func viewDidAppear(animated: Bool) {
  
      if sharedVariables.standartNavBarBackgroundImage == nil {
          let herp = navigationController!.navigationBar.backgroundImageForBarMetrics(.Default)
          sharedVariables.standartNavBarBackgroundImage = herp
          let derp = navigationController!.navigationBar.shadowImage
          sharedVariables.standartNavBarShadowImage = derp
      }
  }
  </code></pre>
  
  <p>Both <code>herp</code> and <code>derp</code> are <code>nil</code> after being set, dispite the navigationbar is visible at this momont. How come?</p>