SegmentedControl background color
Create a custom subclass of UISegmentedControl
(if you don't want to see the divider imageView between the segments):
final class SegmentedControl: UISegmentedControl {
override func layoutSubviews() {
super.layoutSubviews()
(0..<numberOfSegments).forEach { index in
if let subview = subviews[index] as? UIImageView {
subview.isHidden = true
}
}
}
}
(if you want to see the divider imageView between the segments):
final class SegmentedControl: UISegmentedControl {
override func draw(_ rect: CGRect) {
for index in 0..<numberOfSegments {
let view = UIView(frame: subviews[index].bounds)
view.backgroundColor = .white
subviews[index].addSubview(view)
}
}
}
Create an instance of SegmentedControl and don't forget to set selectedSegmentTintColor, segmentedControl.backgroundColor = .white