diff --git a/ATHMultiSelectionSegmentedControl/Classes/ATHMultiSelectionControlSegmentButton.swift b/ATHMultiSelectionSegmentedControl/Classes/ATHMultiSelectionControlSegmentButton.swift index 3eaead1..92f1736 100644 --- a/ATHMultiSelectionSegmentedControl/Classes/ATHMultiSelectionControlSegmentButton.swift +++ b/ATHMultiSelectionSegmentedControl/Classes/ATHMultiSelectionControlSegmentButton.swift @@ -26,6 +26,8 @@ internal class ATHMultiSelectionControlSegmentButton: UIButton { internal var isButtonEnabled: Bool { return _isButtonEnabled } + /// The color of the text when selected + internal var titleColorSelected: UIColor? override var isHighlighted: Bool { @@ -82,9 +84,9 @@ internal class ATHMultiSelectionControlSegmentButton: UIButton { */ fileprivate func _setSelectedState() { - layer.borderColor = backgroundColor?.cgColor + layer.borderColor = self.titleColorSelected?.cgColor backgroundColor = tintColor - setTitleColor(UIColor.white, for: .normal) + setTitleColor(self.titleColorSelected ?? UIColor.white, for: .normal) } diff --git a/ATHMultiSelectionSegmentedControl/Classes/ATHMultiSelectionSegmentedControl.swift b/ATHMultiSelectionSegmentedControl/Classes/ATHMultiSelectionSegmentedControl.swift index 523514b..dd20f02 100644 --- a/ATHMultiSelectionSegmentedControl/Classes/ATHMultiSelectionSegmentedControl.swift +++ b/ATHMultiSelectionSegmentedControl/Classes/ATHMultiSelectionSegmentedControl.swift @@ -171,6 +171,7 @@ open class MultiSelectionSegmentedControl: UIView { button.titleLabel?.font = font button.tintColor = tintColor button.backgroundColor = backgroundColor + button.titleColorSelected = backgroundColor button.setButtonSelected(selectedSegmentIndices.contains(index)) button.addTarget(self, action: #selector(self._didTouchUpInsideSegment(_:)), for: .touchUpInside) @@ -325,8 +326,10 @@ open class MultiSelectionSegmentedControl: UIView { let button = ATHMultiSelectionControlSegmentButton(frame: CGRect(x: self.frame.width, y: 0, width: 0, height: self.frame.height)) + button.titleLabel?.font = font button.tintColor = tintColor button.backgroundColor = backgroundColor + button.titleColorSelected = backgroundColor button.addTarget(self, action: #selector(self._didTouchUpInsideSegment(_:)), for: .touchUpInside) button.setTitle(title, for: .normal)