title: Customizing UISegmentedControl in iOS 5
body: <p>Here is my problem. I am customizing a UISegmentedControl by setting the background and divider images in the following way:</p>
  
  <pre><code>[[UISegmentedControl appearance] setDividerImage:segmentUnselectedUnselected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  [[UISegmentedControl appearance] setDividerImage:segmentSelectedUnselected forLeftSegmentState:UIControlStateSelected rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  [[UISegmentedControl appearance] setDividerImage:segUnselectedSelected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
  
  [[UISegmentedControl appearance] setBackgroundImage:segmentUnselected forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  [[UISegmentedControl appearance] setBackgroundImage:segmentSelected forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
  </code></pre>
  
  <p>When I try to make the 1st segmented selected within <code>viewDidLoad</code></p>
  
  <pre><code>self.segmentedControl.selectedIndex = 1;
  </code></pre>
  
  <p>I get the following weird thing:</p>
  
  <p><img src="https://i.stack.imgur.com/x3zOB.png" alt="enter image description here"></p>
  
  <p>instead of: </p>
  
  <p><img src="https://i.stack.imgur.com/abymP.png" alt="enter image description here"></p>
  
  <p>Does anyone know if this is a bug and how could I provide a bug report? If not, what could be wrong with my code?</p>