diff --git a/CardParts/src/Classes/Card Parts/CardPartSliderView.swift b/CardParts/src/Classes/Card Parts/CardPartSliderView.swift index 457b35d7..f6d3a4cf 100644 --- a/CardParts/src/Classes/Card Parts/CardPartSliderView.swift +++ b/CardParts/src/Classes/Card Parts/CardPartSliderView.swift @@ -12,7 +12,22 @@ import RxCocoa public class CardPartSliderView : UISlider, CardPartView { public var margins: UIEdgeInsets = CardParts.theme.cardPartMargins + public var height: CGFloat + public init(height: CGFloat = 3.0) { + self.height = height + super.init(frame: CGRect.zero) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override public func trackRect(forBounds bounds: CGRect) -> CGRect { + let customBounds = CGRect(origin: bounds.origin, size: CGSize(width: bounds.size.width, height: self.height)) + super.trackRect(forBounds: customBounds) + return customBounds + } } extension Reactive where Base: CardPartSliderView { @@ -28,4 +43,16 @@ extension Reactive where Base: CardPartSliderView { sliderView.maximumValue = maximumValue } } + + public var minimumTrackTintColor: Binder { + return Binder(self.base) { (sliderView, minimumTrackTintColor) -> () in + sliderView.minimumTrackTintColor = minimumTrackTintColor + } + } + + public var maximumTrackTintColor: Binder { + return Binder(self.base) { (sliderView, maximumTrackTintColor) -> () in + sliderView.maximumTrackTintColor = maximumTrackTintColor + } + } } diff --git a/Example/CardParts/CardPartSliderViewCardController.swift b/Example/CardParts/CardPartSliderViewCardController.swift index 4dacb698..b856a02a 100644 --- a/Example/CardParts/CardPartSliderViewCardController.swift +++ b/Example/CardParts/CardPartSliderViewCardController.swift @@ -12,7 +12,7 @@ import CardParts class CardPartSliderViewCardController: CardPartsViewController { let cardPartTextView = CardPartTextView(type: .normal) - let cardPartSliderView = CardPartSliderView() + let cardPartSliderView = CardPartSliderView(height: 8) override func viewDidLoad() { super.viewDidLoad() @@ -22,7 +22,9 @@ class CardPartSliderViewCardController: CardPartsViewController { cardPartSliderView.minimumValue = 0 cardPartSliderView.maximumValue = 100 cardPartSliderView.value = 50 + cardPartSliderView.minimumTrackTintColor = .blue + cardPartSliderView.maximumTrackTintColor = .green - setupCardParts([cardPartTextView, cardPartSliderView]) + setupCardParts([cardPartTextView, CardPartSpacerView(height: 10), cardPartSliderView]) } }