I'm trying display the integer values instead of float. I tried the following:
section.append(SliderRow() {
$0.title = "Number of items"
$0.tag = "numberOfItems"
$0.minimumValue = 1
$0.maximumValue = 10
$0.steps = 10
$0.value = 5
$0.onChange { row in
let isInteger = floor(row.value!) == row.value!
if (!isInteger) {
row.value = floor(row.value!)
}
let formattedString = String(format: "%.0f", row.value!)
row.cell.valueLabel.text = formattedString
}
})
formattedString displays the values I want but I'm not able to display them on the screen. I can access all other attributes by row.cell. I change change the text colour, for instance, but not the text. I'm guessing I'm setting the text but it gets overwritten shortly.
Is there a way to make the slider show integer values?
Thanks.
since Dec 2, 2016, there's a much simpler approach.....
$0.displayValueFor = {
return "\(Int($0 ?? 0))"
}
(credit to https://github.com/xmartlabs/Eureka/issues/817 showing how to do it - and the associated fix)
This works great for showing an Int in the Eureka SliderRow as well as StepperRow See this picture of xcode Simulator showing Int values on StepperRow and SliderRow