Skip to content

Commit

Permalink
Merge branch 'feature/knobHighlightable'
Browse files Browse the repository at this point in the history
  • Loading branch information
why2pac committed Mar 3, 2017
2 parents 9f3b634 + c35ca45 commit 0165ee9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions SwiftRangeSlider/RangeSlider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ import QuartzCore
}


///Whether the knows are highlightable. `true` by default.
@IBInspectable open var knobHighlightable: Bool = true {
didSet {
upperKnob.highlightable = knobHighlightable
lowerKnob.highlightable = knobHighlightable
}
}

var previousLocation = CGPoint()
var previouslySelectedKnob = Knob.Neither

Expand Down Expand Up @@ -251,11 +259,13 @@ import QuartzCore

lowerKnob.frame = CGRect(x: 0, y: 0, width: KnobSize, height: KnobSize)
lowerKnob.rangeSlider = self
lowerKnob.highlightable = knobHighlightable
lowerKnob.contentsScale = UIScreen.main.scale
layer.addSublayer(lowerKnob)

upperKnob.frame = CGRect(x: 0, y: 0, width: KnobSize, height: KnobSize)
upperKnob.rangeSlider = self
upperKnob.highlightable = knobHighlightable
upperKnob.contentsScale = UIScreen.main.scale
layer.addSublayer(upperKnob)

Expand Down
4 changes: 3 additions & 1 deletion SwiftRangeSlider/RangeSliderKnob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public enum KnobAnchorPosition {
class RangeSliderKnob: CALayer {
static var KnobDelta: CGFloat = 2.0

var highlightable: Bool = true

var highlighted: Bool = false {
didSet {
if let superLayer = superlayer, highlighted {
Expand Down Expand Up @@ -54,7 +56,7 @@ class RangeSliderKnob: CALayer {
ctx.addPath(knobPath.cgPath)
ctx.strokePath()

if highlighted {
if highlighted && highlightable {
ctx.setFillColor(UIColor(white: 0.0, alpha: 0.1).cgColor)
ctx.addPath(knobPath.cgPath)
ctx.fillPath()
Expand Down

0 comments on commit 0165ee9

Please sign in to comment.