IOS Programmer - 9 months ago 73

Swift Question

I've tried to make a slider to show a percentage out of 100, but the label doesn't show that value correctly.

Answer

A `UISlider`

has a default min and max of 0 and 1. So the slider is sending all kinds of fractional values as you move the slider such as 0.153343 and .53453545, etc. But you convert that number to an `Int`

. That leaves you with only 0 and 1.

Either multiply the `sender.value * 100`

or change the slider's max value to 100.