title: UISegmentedControl - Changing Colors and Size - Not working Right
body: <p>I want to be able to Change the Colors and font size of the Segments of a UISegmentedControl.  I'm setting the tag for each segment and then setting the tintColor: forTag: for each of the segments. </p>
  
  <p>Changing the Colors works great, till I pan the control or Pinch it.   In the UIPinchGestureRecognizer code I set the titleTextAttributes to have a different Font Size.  When I do this, the Colors of the Segments revert back to the default Gary Color. </p>
  
  <pre><code>- (void)createElement {
  if (multiStateControl == nil) {
  
          //Make our new switch
          //multiStateControl = [UIButton  buttonWithType:UIButtonTypeCustom];
  
      multiStateControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Off State Button", @"On State Button", nil]];
  
       multiStateControl.segmentedControlStyle = UISegmentedControlStyleBar;
  
      [multiStateControl setTitleTextAttributes:
       [NSDictionary dictionaryWithObjectsAndKeys:
        [UIFont boldSystemFontOfSize:12.0f], UITextAttributeFont, 
  
        nil] 
                                       forState:UIControlStateNormal]; 
  
       [multiStateControl setFrame:CGRectMake(0.0f, 0.0f, 100.0f, 30.0f)];
  
          // Set up the Contents Frame to the same origin as what we were but set the height/width to the new control.
      [elementViewContents setFrame:CGRectMake(elementViewContents.frame.origin.x, 
                                               elementViewContents.frame.origin.y, 
                                               CGRectGetWidth(multiStateControl.frame), 
                                               CGRectGetHeight(multiStateControl.frame))];
  
  
          //Set initial use to disabled
      [multiStateControl setOpaque:NO];
          // Set the default title for the button
              [multiStateControl setTag:kTagOffState forSegmentAtIndex:0];
              [multiStateControl setTag:kTagOnState forSegmentAtIndex:1];
              [multiStateControl setTintColor:onColor forTag:kTagOnState];
          [multiStateControl setTintColor:offColor forTag:kTagOffState];  
  
          // Lets get it on the screen
      [elementViewContents addSubview:multiStateControl];
     [multiStateControl release];
  
      [self contentSizeChanged];
  }       
  }
  </code></pre>
  
  <p>//Pinch Gesture</p>
  
  <pre><code>-(void) pinchElement:(UIPinchGestureRecognizer *)gestureRecognizer  {
  
      UIFont *existingFont = [[multiStateControl titleTextAttributesForState:UIControlStateNormal] objectForKey:UITextAttributeFont];
  
      CGFloat existingFontSize = [existingFont pointSize];
      CGFloat newFontSize = existingFontSize * [gestureRecognizer scale] ;
  
      [multiStateControl setTitleTextAttributes:
            [NSDictionary dictionaryWithObjectsAndKeys:
            [UIFont boldSystemFontOfSize:newFontSize],
            UITextAttributeFont, nil] 
                                       forState:UIControlStateNormal]; 
  
      [multiStateControl setFrame:CGRectMake(multiStateControl.frame.origin.x, multiStateControl.frame.origin.y, multiStateControl.frame.size.width+20,newFontSize *1.8)];
  }
  </code></pre>