Skip to content

Instantly share code, notes, and snippets.

@prendio2
Last active December 22, 2015 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prendio2/6424749 to your computer and use it in GitHub Desktop.
Save prendio2/6424749 to your computer and use it in GitHub Desktop.
+ (void)initialize
{
//Unselected Background
[[UISegmentedControl appearance] setBackgroundImage:[UIImage imageNamed:@"UISegmentedControlBackgroundUnselected"]
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
//Selected Background
[[UISegmentedControl appearance] setBackgroundImage:[UIImage imageNamed:@"UISegmentedControlBackgroundSelected"]
forState:UIControlStateSelected
barMetrics:UIBarMetricsDefault];
//Highlighted Background
[[UISegmentedControl appearance] setBackgroundImage:[UIImage imageNamed:@"UISegmentedControlBackgroundHighlighted"]
forState:UIControlStateHighlighted
barMetrics:UIBarMetricsDefault];
#warning dual state not working
//This is supposed to set background image for when a segment is both selected and highlighted
//so it doesn't revert to the highlighted state. Doesn't work however and when I tap on the
//selected item it takes the highlighted background from above.
[[UISegmentedControl appearance] setBackgroundImage:[UIImage imageNamed:@"UISegmentedControlBackgroundSelected"]
forState:(UIControlStateSelected|UIControlStateHighlighted)
barMetrics:UIBarMetricsDefault];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment