Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mhijack/c812e9ecea7044f4a6d013f26252a75a to your computer and use it in GitHub Desktop.
Save mhijack/c812e9ecea7044f4a6d013f26252a75a to your computer and use it in GitHub Desktop.
private var progressBarHighlightedObserver: NSKeyValueObservation?
private lazy var progressBar: UISlider = {
let bar = UISlider()
bar.minimumTrackTintColor = .red
bar.maximumTrackTintColor = .white
bar.value = 0.0
bar.isContinuous = false
bar.addTarget(self, action: #selector(handleSliderChange), for: .valueChanged)
self.progressBarHighlightedObserver = bar.observe(\UISlider.isTracking, options: [.old, .new]) { (_, change) in
if let newValue = change.newValue {
self.didChangeProgressBarDragging?(newValue, bar.value)
}
}
return bar
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment