Skip to content

Commit

Permalink
added linecolor property
Browse files Browse the repository at this point in the history
  • Loading branch information
askopin committed Feb 18, 2019
1 parent 57f1ee2 commit d435287
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rubber-range-picker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'rubber-range-picker'
s.version = '0.8.0'
s.version = '0.8.1'
s.swift_version = '4.2'
s.summary = 'Two-sided slider with elastic behavior'
s.homepage = 'https://github.com/Cuberto/rubber-range-picker'
Expand Down
21 changes: 15 additions & 6 deletions rubber-range-picker/Classes/RubberRangePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@ import UIKit

open override var tintColor: UIColor! {
didSet {
trackLayer.outerColor = .lightGray
trackLayer.innerColor = tintColor
trackLayer.setNeedsDisplay()
lowerThumb.tintColor = tintColor
upperThumb.tintColor = tintColor
}
}

open var lineColor: UIColor! = #colorLiteral(red: 0.862745098, green: 0.862745098, blue: 0.9294117647, alpha: 1) {
didSet {
trackLayer.outerColor = lineColor
trackLayer.setNeedsDisplay()
}
}

open var thumbSize: CGFloat = 40.0 {
didSet {
trackLayer.margin = thumbSize/2.0
Expand Down Expand Up @@ -91,7 +97,7 @@ import UIKit
}


private let trackLayer = RubberTrackLayer()
private var trackLayer = RubberTrackLayer()
private var lowerThumb = RubberRangeThumb()
private var upperThumb = RubberRangeThumb()
private var previousLocation = CGPoint()
Expand All @@ -107,7 +113,7 @@ import UIKit
private var upperStartOffset: CGFloat?

private var vertOffset: CGFloat = 0

public override init(frame: CGRect) {
super.init(frame: frame)
configure()
Expand All @@ -126,6 +132,9 @@ import UIKit

private func configure() {
tintColor = #colorLiteral(red: 0.168627451, green: 0.6745098039, blue: 0.9882352941, alpha: 1)
trackLayer.innerColor = tintColor
trackLayer.outerColor = lineColor
trackLayer.behavior = elasticBehavior
lowerThumb.isUserInteractionEnabled = false
upperThumb.isUserInteractionEnabled = false
layer.addSublayer(trackLayer)
Expand All @@ -137,7 +146,7 @@ import UIKit
width: thumbSize, height: thumbSize)
displayLink.add(to: .current, forMode: .common)
}

open override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
previousLocation = touch.location(in: self)
vertOffset = 0
Expand Down Expand Up @@ -246,7 +255,7 @@ import UIKit
y: (bounds.height - thumbSize)/2.0 + upperVertOffset,
width: thumbSize, height: thumbSize)
updateTrackLayer()

}

private func springCoordinate(forTime time: CGFloat, offset: CGFloat) -> CGFloat {
Expand All @@ -260,7 +269,7 @@ import UIKit

return A * exp(-beta * time) * cos(omega * time)
}

private func updateTrackLayer() {
trackLayer.frame = bounds
trackLayer.lowerOffset = lowerThumb.frame.midX
Expand Down

0 comments on commit d435287

Please sign in to comment.