<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "tvOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureDevice/setExposureModeCustom(lensAperture:duration:iso:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureDevice(im)setExposureModeCustomWithLensAperture:duration:ISO:completionHandler:"
  },
  "title" : "setExposureModeCustom(lensAperture:duration:iso:completionHandler:)"
}
-->

# setExposureModeCustom(lensAperture:duration:iso:completionHandler:)

Sets a custom exposure mode with the specified lens aperture, exposure duration, and ISO values.

```
func setExposureModeCustom(lensAperture: Float, duration: CMTime, iso ISO: Float, completionHandler handler: (@Sendable (CMTime) -> Void)? = nil)
```

```
func setExposureModeCustom(lensAperture: Float, duration: CMTime, iso ISO: Float) async -> CMTime
```

## Parameters

`lensAperture`

The lens aperture, as described in the documentation for the [`lensAperture`](/documentation/AVFoundation/AVCaptureDevice/lensAperture) property. You may specify one of the special `AVFCapture/AVCaptureLensApertureCurrent` or `AVFCapture/AVCaptureLensApertureAuto` constants listed in the discussion section below, or values between the [`minLensAperture`](/documentation/AVFoundation/AVCaptureDevice/Format/minLensAperture) and [`maxLensAperture`](/documentation/AVFoundation/AVCaptureDevice/Format/maxLensAperture) of the [`activeFormat`](/documentation/AVFoundation/AVCaptureDevice/activeFormat).

`duration`

The exposure duration, as described in the documentation for the [`exposureDuration`](/documentation/AVFoundation/AVCaptureDevice/exposureDuration) property. You may specify one of the special `AVFCapture/AVCaptureExposureDurationCurrent` or `AVFCapture/AVCaptureExposureDurationAuto` constants listed in the discussion section below, or values between the [`minExposureDuration`](/documentation/AVFoundation/AVCaptureDevice/Format/minExposureDuration) and [`maxExposureDuration`](/documentation/AVFoundation/AVCaptureDevice/Format/maxExposureDuration) of the [`activeFormat`](/documentation/AVFoundation/AVCaptureDevice/activeFormat).

`ISO`

The exposure ISO value, as described in the documentation for the [`iso`](/documentation/AVFoundation/AVCaptureDevice/iso) property. You may specify one of the special `AVFCapture/AVCaptureISOCurrent` or `AVFCapture/AVCaptureISOAuto` constants listed in the discussion section below, or values between the [`minISO`](/documentation/AVFoundation/AVCaptureDevice/Format/minISO) and [`maxISO`](/documentation/AVFoundation/AVCaptureDevice/Format/maxISO) of the [`activeFormat`](/documentation/AVFoundation/AVCaptureDevice/activeFormat).

`handler`

A block to be called when all parameters have been set to the values specified and [`exposureMode`](/documentation/AVFoundation/AVCaptureDevice/exposureMode-swift.property) is set to [`AVCaptureDevice.ExposureMode.custom`](/documentation/AVFoundation/AVCaptureDevice/ExposureMode-swift.enum/custom). If the `setExposureModeCustom...` methods are called multiple times, their completion handlers are always called in FIFO order. The block receives a timestamp which matches that of the first buffer to which all settings have been applied. Note that the timestamp is synchronized to the device clock, and thus must be converted to the [`synchronizationClock`](/documentation/AVFoundation/AVCaptureSession/synchronizationClock) prior to comparison with the timestamps of buffers delivered via an [`AVCaptureVideoDataOutput`](/documentation/AVFoundation/AVCaptureVideoDataOutput). The client may pass nil for the handler parameter if knowledge of the operation’s completion is not required.

## Discussion

Besides a numeric value, each of the exposure parameters can be set to either of these special constants:

> Lock To Current Value:
> A value of ``AVFCapture/AVCaptureLensApertureCurrent`` can be passed for `lensAperture`, or ``AVFCapture/AVCaptureExposureDurationCurrent`` for `duration`, or ``AVFCapture/AVCaptureISOCurrent`` for `ISO`, to indicate you wish to lock that parameter at the current value.  When auto-exposure is active, it is preferable to use these constants rather than querying the property getter, as auto-exposure system may be asynchronously changing the value as the command is processed.
> 
> Passing ``AVFCapture/AVCaptureLensApertureCurrent`` is equivalent to calling ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/setExposureModeCustom(duration:iso:completionHandler:)``.

> Priority Modes:
> A value of ``AVFCapture/AVCaptureLensApertureAuto`` can be passed for `lensAperture`, or ``AVFCapture/AVCaptureExposureDurationAuto``  for `duration`, or ``AVFCapture/AVCaptureISOAuto`` for `ISO`, to indicate the auto-exposure system should continue to manage that parameter to produce balanced image brightness.  This allows you to lock one of the exposure parameters (the “priority”) while the system will automatically adjust the other.
> 
> Not all priority mode combinations may be supported. Use ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/Format/supportsExposureModeCustom(lensAperture:duration:iso:)`` to validate whether a given configuration will be accepted.

The applied exposure duration of streaming frames are limited to [`activeMaxExposureDuration`](/documentation/AVFoundation/AVCaptureDevice/activeMaxExposureDuration) when either lensAperture or ISO is set to “Auto”, but the full exposure duration may be applied during still capture.  Auto parameter(s) will attempt to simulate how a still capture will appear, while maintaining the current frame rate for responsive preview.  If none of the parameters are “Auto”, changes to the exposure duration may result in changes to [`activeVideoMaxFrameDuration`](/documentation/AVFoundation/AVCaptureDevice/activeVideoMaxFrameDuration).

If you wish to use the custom locked values for [`AVCapturePhotoOutput`](/documentation/AVFoundation/AVCapturePhotoOutput) captures, you must set the [`photoQualityPrioritization`](/documentation/AVFoundation/AVCapturePhotoSettings/photoQualityPrioritization) property to [`AVCapturePhotoOutput.QualityPrioritization.speed`](/documentation/AVFoundation/AVCapturePhotoOutput/QualityPrioritization/speed). The default value of [`AVCapturePhotoOutput.QualityPrioritization.balanced`](/documentation/AVFoundation/AVCapturePhotoOutput/QualityPrioritization/balanced) allows photo capture to temporarily override the capture device’s ISO and exposureDuration values if the scene is dark enough to warrant some form of multi-image fusion to improve quality.

Note selecting speed prioritization disables image stabilization. If you then re-enable image stabilization via the deprecated [`isAutoStillImageStabilizationEnabled`](/documentation/AVFoundation/AVCapturePhotoSettings/isAutoStillImageStabilizationEnabled) property or [`automaticallyEnablesStillImageStabilizationWhenAvailable`](/documentation/AVFoundation/AVCaptureStillImageOutput/automaticallyEnablesStillImageStabilizationWhenAvailable) property, this counteracts speed prioritization and can result in image capture adopting different exposure settings.

> Throws: `NSRangeException` if any parameter is set to an unsupported level.

> Throws: `NSInvalidArgumentException` if the custom mode is not supported.  (See ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/Format/supportsExposureModeCustom(lensAperture:duration:iso:)``)

> Throws: `NSGenericException` if called without first obtaining exclusive access to the receiver using ``doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/lockForConfiguration()``.

---

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)