Added haptic feedback to tick mark slider.

This commit is contained in:
Maurice Parker 2019-11-08 20:38:24 -06:00
parent 29b7215f5c
commit f687fc96a6
1 changed files with 13 additions and 0 deletions

View File

@ -10,8 +10,21 @@ import UIKit
class TickMarkSlider: UISlider {
private var enableFeedback = false
private let feedbackGenerator = UISelectionFeedbackGenerator()
override var value: Float {
didSet {
if enableFeedback && value.truncatingRemainder(dividingBy: 1) == 0 {
feedbackGenerator.selectionChanged()
}
}
}
func addTickMarks() {
enableFeedback = true
let numberOfGaps = Int(maximumValue) - Int(minimumValue)
var gapLayoutGuides = [UILayoutGuide]()