Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrease Slider ball size?

Tags:

swiftui

Is there a way to decrease or increase the slider ball size in swiftui?

enter image description here


2 Answers

For some reason .controlSize(_:) modifier is not working for me.

But I found a decent solution without using UIViewRepresentable and Third-party libraries.

Just add UIKit customisation you need inside .onAppear() modifier and that's it.

Slider(value: $currentValueProgress, in: 0...100, step: 1)
            .accentColor(.white)
            .onAppear {
                let progressCircleConfig = UIImage.SymbolConfiguration(scale: .small)
                UISlider.appearance()
                    .setThumbImage(UIImage(systemName: "circle.fill",
                                           withConfiguration: progressCircleConfig), for: .normal)
            }
like image 69
ViOS Avatar answered Oct 27 '25 03:10

ViOS


you can also add the .controlSize(_:) modifier. The options are: .mini, .small and .regular

like image 39
Peter Avatar answered Oct 27 '25 04:10

Peter