mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Make sliders should be quantized. Issue #1342
This commit is contained in:
@@ -17,4 +17,11 @@ class CroppingPreviewParameters: UIPreviewParameters {
|
||||
self.visiblePath = visiblePath
|
||||
}
|
||||
|
||||
init(view: UIView, size: CGSize) {
|
||||
super.init()
|
||||
let newBounds = CGRect(x: 0, y: 0, width: size.width, height: size.height)
|
||||
let visiblePath = UIBezierPath(roundedRect: newBounds, cornerRadius: 10)
|
||||
self.visiblePath = visiblePath
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,9 +13,12 @@ class TickMarkSlider: UISlider {
|
||||
private var enableFeedback = false
|
||||
private let feedbackGenerator = UISelectionFeedbackGenerator()
|
||||
|
||||
private var roundedValue: Float?
|
||||
override var value: Float {
|
||||
didSet {
|
||||
if enableFeedback && value.truncatingRemainder(dividingBy: 1) == 0 {
|
||||
let testValue = value.rounded()
|
||||
if testValue != roundedValue && enableFeedback && value.truncatingRemainder(dividingBy: 1) == 0 {
|
||||
roundedValue = testValue
|
||||
feedbackGenerator.selectionChanged()
|
||||
}
|
||||
}
|
||||
@@ -66,6 +69,12 @@ class TickMarkSlider: UISlider {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override func continueTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
|
||||
let result = super.continueTracking(touch, with: event)
|
||||
value = value.rounded()
|
||||
return result
|
||||
}
|
||||
|
||||
override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
|
||||
value = value.rounded()
|
||||
|
||||
Reference in New Issue
Block a user