---
title: "setValue(_:animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uislider/setvalue(_:animated:)"
---

# setValue(_:animated:)

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

## Declaration

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

## Parameters

- `value`: The new value to assign to the doc://com.apple.uikit/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

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 property to 0.0.

## See Also

### Accessing the slider’s value

- [value](uikit/uislider/value.md)
