title: swiftui button control slider
body: <p>I want to use the button to control the slider, as shown below.<a href="https://i.stack.imgur.com/vaoUR.png" rel="nofollow noreferrer">want plus, minus button can control the slider</a></p>
  <p>I can only successfully use the stepper to control the slider, but the stepper is not the shape I want. Why can't I control the slider in the following way of writing?
  `</p>
  <pre><code>var body: some View {
     
      VStack{
          Spacer()
              .frame(height:20)
          HStack{
              Text(&quot;Exposure&quot;)
                  .foregroundColor(.white)
              Spacer()
              Toggle(&quot;Auto&quot;,isOn:$autoValue)
          }
          Spacer()
              .frame(height:5)
          HStack{
              let scaleString = controllerSettting.exposureTime.sliderValue.formatted(.number.precision(.fractionLength(0)))
              
              Button(&quot;-&quot;){
                    controllerSettting.exposureTime.sliderValue = Float(controllerSettting.exposureTime.sliderValue) - 1
              }
              Slider(value: $controllerSettting.exposureTime.sliderValue, in:
                      controllerSettting.exposureTime.minimum...controllerSettting.exposureTime.maximum)
  
              Button(&quot;+&quot;){
                  controllerSettting.exposureTime.sliderValue = Float(controllerSettting.exposureTime.sliderValue) + 1
                  
              }
              TextField(scaleString, text: $message)
  
              Button(&quot;Reset&quot;){
                  controllerSettting.exposureTime.reset()  
              }
  
          }`
  </code></pre>
  <p>I want the button to be reacted instantly on the slider (the slider will move and the textField will change).</p>
  <p>thank you all</p>