title: customize UISegmentedControl with resizableImageWithCapInsets
body: <p>I am customize UISegmentedControl with custom background images. 
  Code is like this:</p>
  
  <pre><code>UIImage *segmentSelected = [[UIImage imageNamed:@"segcontrol_sel.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
  UIImage *segmentUnselected = [[UIImage imageNamed:@"segcontrol_uns.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
  UIImage *segmentSelectedUnselected = [[UIImage imageNamed:@"segcontrol_sel-uns.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
  UIImage *segUnselectedSelected = [[UIImage imageNamed:@"segcontrol_uns-sel.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
  UIImage *segmentUnselectedUnselected = [[UIImage imageNamed:@"segcontrol_uns-uns.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
  
  [[UISegmentedControl appearance] setBackgroundImage:segmentUnselected
                                             forState:UIControlStateNormal
                                           barMetrics:UIBarMetricsDefault];
  
  [[UISegmentedControl appearance] setBackgroundImage:segmentSelected
                                             forState:UIControlStateSelected
                                           barMetrics:UIBarMetricsDefault];
  
  [[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];
  </code></pre>
  
  <p>But the result is not what it is supposed to be. I am not very sure about the usage of the method: resizableImageWithCapInsets.
  image is attached. </p>
  
  <p>it should be like this: 
  <img src="https://i.stack.imgur.com/EbxTS.png" alt="should be"></p>
  
  <p>but actually it is like this: 
  <img src="https://i.stack.imgur.com/8iTRT.png" alt="screen shot"></p>
  
  <p>I guess I used the wrong UIEdgeInset value. 
  The background image is of width: 22; height: 30
  and the divider image is of width: 11; height: 30
  Any suggestion?</p>