I have a Circle Slider and want to Display the dayTime in the center of it . So in the code you can see countmin is the max min of the Slider. For Hours it runs but for minutes it´s set the Time to 60 min max min Slider but i need it that set it always next to new hour to set it to null. Have anything an idea what i can make there that i get the correct Time from the Minutes? 11:59
Thanks for Help
func valueChange(_ sender: CircleSlider) {
var countmin = Int(Double(sender.value) * 14.4)
minutes! = countmin / 24
hours! = countmin / 60
print("\(minutes)min")
print("\(hours)hou")
self.circleTime.text = "\(hours!):\(minutes!)"
}
I'm assuming countmin is the number of minutes, and maybe you're thinking too much about this. Also, try to avoid force unwrapping variables unless you have to.
func valueChange(_ sender: CircleSlider) {
var countmin = Int(Double(sender.value) * 14.4)
let hours:Int = countmin/60
let minutes = countmin - (hours*60)
print("\(minutes)min")
print("\(hours)hou")
self.circleTime.text = "\(hours):\(minutes)"
}