I created a UISlider via SwiftUI, but there are just too many "step marks" along the track, which doesn't have the "look and feel" I wish to achieve. Anyone knows the trick to remove them other than turning the tint color to black?
It seems that the step/tick marks are always there as long as I pass any step values during UISlider initialization.
struct setLoggingView: View {
@State var restfullness: Int
@State var elapsedRestTime: Double
var totalRestTime: Double
var stepValue: Int
var body: some View {
GeometryReader { geometry in
ScrollView {
VStack {
Text("Rested \(Int(elapsedRestTime)) seconds")
Slider(value: $elapsedRestTime,
in: 0...totalRestTime,
step: Double.Stride(stepValue),
label: {
Text("Slider")
}, minimumValueLabel: {
Text("-\(stepValue)")
}, maximumValueLabel: {
Text("+\(stepValue)")
})
.tint(Color.white)
.padding(.bottom)
Divider()
Spacer()
Text("Restfullness")
.frame(minWidth: 0, maxWidth: .infinity)
restfullnessStepper(restfullnessIndex: restfullness)
Button(action: {
print("Update Button Pressed")
}) {
HStack {
Text("Update")
.fontWeight(.medium)
}
}
.cornerRadius(40)
}
.border(Color.yellow)
}
}
}
}
Tried research and asked a few mentors, but there seems to be no way to remove the steppers if you are using the default UISlider in SwiftUI. The only way is to create completely custom Slider, but I think I will just live with the default version.