title: iOS UINavigationBar tint color appears darker than color set
body: <p>I am setting a custom appearance for a specific navigation controller:</p>
  
  <pre><code>//Set Cutom Nav Bar Appearance
  [[UINavigationBar appearanceWhenContainedIn:[MyNavigationControllerClass class], nil] setBackgroundImage: nil forBarMetrics: UIBarMetricsDefault];
  [[UINavigationBar appearanceWhenContainedIn:[MyNavigationControllerClass class], nil] setBarTintColor: self.tableView.backgroundColor];
  </code></pre>
  
  <p>When the navigation controller is displayed, the expected color is RGB(247, 247, 247) - which I have double checked is also the value of the tableView.background color when the value is set - but it appears on screen as RGB( 227, 227, 227). Could there be a different property of UINavigationBar's appearance proxy that is changing the color displayed on screen?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Additionally, if I set the barTintColor directly using the desired color, the barTintColor displayed on screen is still darker than expected:</p>
  
  <pre><code>UIColor* navBarBackgroundColor = [UIColor colorWithRed: (247.0 / 255.0) green: (247.0 / 255.0) blue: (247.0 / 255.0) alpha: 1];
  //Set Cutom Nav Bar Appearance
  [[UINavigationBar appearanceWhenContainedIn:[MyNavigationControllerClass class], nil] setBackgroundImage: nil forBarMetrics: UIBarMetricsDefault];
  [[UINavigationBar appearanceWhenContainedIn:[MyNavigationControllerClass class], nil] setBarTintColor: navBarBackgroundColor];
  </code></pre>
  
  <p><strong>Solution</strong></p>
  
  <p>Here is the solution code derived from @Matt's answer. Hope it helps someone out</p>
  
  <pre><code>CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
  UIGraphicsBeginImageContext(rect.size);
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextSetFillColorWithColor(context, [self.tableView.backgroundColor CGColor]);
  CGContextFillRect(context, rect);
  UIImage *navBarImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  
  //Set Cutom Nav Bar Appearance
  [[UINavigationBar appearanceWhenContainedIn:[MyNavigationControllerClass class], nil] setBackgroundImage: navBarImage forBarMetrics: UIBarMetricsDefault];
  </code></pre>