---
title: "init(device:action:)"
framework: avfoundation
role: symbol
role_heading: Initializer
path: "avfoundation/avcapturesystemzoomslider/init(device:action:)"
---

# init(device:action:)

Creates a slider to control the zoom level of the specified capture device with an action to respond to zoom changes.

## Declaration

```swift
init(device: AVCaptureDevice, action: @escaping @MainActor @Sendable (CGFloat) -> Void)
```

## Parameters

- `device`: The capture device to control.
- `action`: An action the system calls on the main actor to respond to changes to the device’s doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/videoZoomFactor property.

## Discussion

Discussion The system calls the specified action only when the zoom slider changes the device’s videoZoomFactor property value. If your app needs to react to other sources of video zoom factor changes like ramp(toVideoZoomFactor:withRate:), use key-value observation instead. important: Don’t change the capture device’s video zoom factor when the system calls the action.

## See Also

### Creating a zoom slider

- [init(device:)](avfoundation/avcapturesystemzoomslider/init(device:).md)
