@Portland Runner Answer for the old version of Swift.
Swift 3.0, it works.
The logic is the same as Runner @Portland, but the syntax has been changed and updated in accordance with Swift 3.0
Here, this code that I implemented is an extension for segment control and can be used for all segment controls in the application, where the code set must be defined in the application class.
extension UISegmentedControl { func setSegmentStyle() { setBackgroundImage(imageWithColor(color: backgroundColor!), for: .normal, barMetrics: .default) setBackgroundImage(imageWithColor(color: tintColor!), for: .selected, barMetrics: .default) setDividerImage(imageWithColor(color: UIColor.clear), forLeftSegmentState: .normal, rightSegmentState: .normal, barMetrics: .default) let segAttributes: NSDictionary = [ NSForegroundColorAttributeName: UIColor.gray, NSFontAttributeName: UIFont(name: "System-System", size: 14)! ] setTitleTextAttributes(segAttributes as [NSObject : AnyObject], for: UIControlState.selected) }
You can use the code below for segments.
self.mySegment.setSegmentStyle()

source share