Created
February 17, 2022 05:01
-
-
Save AndyDentFree/cbc54c2367b98e3489ec15f4b7e747ee to your computer and use it in GitHub Desktop.
Code reacting to a slider change with quantised steps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction public func onThicknesssliderChanged(_ sender: UISlider) { | |
let step: Float = 0.25 // using 0.1 causes text render backwards & slanted! Very weird SKLabel internal bug | |
let roundedValue = roundf(sender.value / step) * step | |
sender.value = roundedValue // force it to jump in increments | |
updatePreviewFromThicknessChange() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment