//Set default tint color. This will set text color and border color
[[UISegmentedControl appearance] setTintColor:[UIColor whiteColot]];
// Set background image for normal and selected state. This will appear on top of the border and cover the actual border.
[[UISegmentedControl appearance] setBackgroundImage:[UIImage imageNamed:@"btn-blue-shade-1"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearance] setBackgroundImage:[UIImage imageNamed:@"btn-blue-shade-2"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
This extension can be used in anywhere of code where the UIsegment control is used.
myUISegment.setSegmentStyle()
This will apply all the styles that are applied to the segment control.
Note: Here in this sample I have removed default border, changed font, set different colors during normal , Selected mode, border explicitly made some colors.
Based on your requirement and colors you can change accordingly as green or any customized color which also shown in sample "segmentGrayColor"
NSArray *arri = [segment subviews];
// Change the tintColor of each subview within the array:
[[arri objectAtIndex:0] setTintColor:[UIColor redColor]];
[[arri objectAtIndex:1] setTintColor:[UIColor greenColor]];
A simple solution:
try this
In swift try this:
its because, each Segment is a View, you can custom it However you want
Extension method code for the Segment Control.
This is working code with Latest Swift 3.0 [March 2017]
The Extension method is created, as the extension to the native segment control.
This extension can be used in anywhere of code where the UIsegment control is used.
This will apply all the styles that are applied to the segment control.
Note: Here in this sample I have removed default border, changed font, set different colors during normal , Selected mode, border explicitly made some colors.
Based on your requirement and colors you can change accordingly as green or any customized color which also shown in sample "segmentGrayColor"
Try like this.