title: How do a set an opaque 1px high shadow image for a UINavigationBar?
body: <p>In my application delegate's didFinishLaunchingWithOptions function, I try to customize the appearance of my navigation bar.</p>
  
  <pre><code>[UINavigationBar appearance].translucent = NO;
  [[UINavigationBar appearance] 
      setBackgroundImage:[UIImage 
          imageWithColor:[UIColor whiteColor] 
          size:CGSizeMake(1.0f, 1.0f)
      ] 
      forBarMetrics:UIBarMetricsDefault
  ];
  [UINavigationBar appearance].shadowImage = [UIImage 
      imageWithColor:[UIColor redColor] 
      size:CGSizeMake(0.5f, 0.5f)
  ];
  </code></pre>
  
  <p>I expect a 1px tall opaque red shadow. Instead I am given a 2px tall translucent red shadow. How can make it appear exactly as I want it to? I've done the analogous appearance settings to UITabBar. It, on the other hand, behaves nicely.</p>
  
  <p><img src="https://i.stack.imgur.com/RKFds.png" alt="enter image description here"></p>
  
  <p>The category function that creates dynamic images is defined as so:</p>
  
  <pre><code>+ (UIImage*)imageWithColor:(UIColor *)color size:(CGSize)size
  {
      CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
      UIGraphicsBeginImageContext(rect.size);
      CGContextRef context = UIGraphicsGetCurrentContext();
      CGContextSetFillColorWithColor(context, [color CGColor]);
      CGContextFillRect(context, rect);
      UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
      return image;
  }
  </code></pre>