<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISlider/setValue(_:animated:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISlider(im)setValue:animated:"
  },
  "title" : "setValue(_:animated:)"
}
-->

# setValue(_:animated:)

Sets the slider’s current value, allowing you to animate the change visually.

```
func setValue(_ value: Float, animated: Bool)
```

## Parameters

`value`

The new value to assign to the [`value`](/documentation/UIKit/UISlider/value) property

`animated`

Specify <doc://com.apple.documentation/documentation/Swift/true> to animate the change in value; otherwise, specify <doc://com.apple.documentation/documentation/Swift/false> to update the slider’s appearance immediately. Animations are performed asynchronously and do not block the calling thread.

## Discussion

If you specify a value that is beyond the minimum or maximum values, the slider limits the value to the minimum or maximum. For example, if the minimum value is 0.0 and you specify -1.0, the slider sets the [`value`](/documentation/UIKit/UISlider/value) property to 0.0.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)