title: Programmatically changing UIButton font color depending on state
body: <p>I'm trying to programmatically create a UIButton. However by default it's turning up white (which is the default color for my navigation bar, I feel that's relevant). I want it to just be Apple's default blue color in iOS7. I've managed to change the color for it's default state, but the moment I select it the text becomes white again. I cannot figure out how to keep it blue.</p>
  
  <p>Could someone please explain to me how I can programmatically create a UIButton and have it act the same as though I created it in storyboard?</p>
  
  <p>Current code:</p>
  
  <pre><code>UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
  cancelButton.frame = CGRectMake(320 - 150, 0, 140, 40);
  [cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
  cancelButton.titleLabel.tintColor = [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0];
  cancelButton.titleLabel.textColor = [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0];
  </code></pre>
  
  <p>Thank you.</p>