---
title: "setExposureModeCustom(lensAperture:duration:iso:completionHandler:)"
framework: AVFoundation
role: symbol
role_heading: Instance Method
platforms: [iOS 27.0+, iPadOS 27.0+, Mac Catalyst 27.0+, tvOS 27.0+]
path: "avfoundation/avcapturedevice/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.

## Declaration

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

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

## Parameters

- `lensAperture`: The lens aperture, as described in the documentation for the doc://com.apple.avfoundation/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 doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/Format/minLensAperture and doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/Format/maxLensAperture of the doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/activeFormat.
- `duration`: The exposure duration, as described in the documentation for the doc://com.apple.avfoundation/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 doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/Format/minExposureDuration and doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/Format/maxExposureDuration of the doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/activeFormat.
- `ISO`: The exposure ISO value, as described in the documentation for the doc://com.apple.avfoundation/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 doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/Format/minISO and doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/Format/maxISO of the doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/activeFormat.
- `handler`: A block to be called when all parameters have been set to the values specified and doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureDevice/exposureMode-swift.property is set to doc://com.apple.avfoundation/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 doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureSession/synchronizationClock prior to comparison with the timestamps of buffers delivered via an doc://com.apple.avfoundation/documentation/AVFoundation/AVCaptureVideoDataOutput. The client may pass nil for the handler parameter if knowledge of the operation’s completion is not required.

## Discussion

Discussion Besides a numeric value, each of the exposure parameters can be set to either of these special constants: note: 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 setExposureModeCustom(duration:iso:completionHandler:). note: 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 supportsExposureModeCustom(lensAperture:duration:iso:) to validate whether a given configuration will be accepted. The applied exposure duration of streaming frames are limited to 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. If you wish to use the custom locked values for AVCapturePhotoOutput captures, you must set the photoQualityPrioritization property to AVCapturePhotoOutput.QualityPrioritization.speed. The default value of 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 property or automaticallyEnablesStillImageStabilizationWhenAvailable property, this counteracts speed prioritization and can result in image capture adopting different exposure settings. note: NSRangeException if any parameter is set to an unsupported level. note: NSInvalidArgumentException if the custom mode is not supported.  (See supportsExposureModeCustom(lensAperture:duration:iso:)) note: NSGenericException if called without first obtaining exclusive access to the receiver using lockForConfiguration().

## See Also

### Configuring exposure manually

- [setExposureModeCustom(duration:iso:completionHandler:)](avfoundation/avcapturedevice/setexposuremodecustom(duration:iso:completionhandler:).md)
- [autoExposureDuration](avfoundation/avcapturedevice/autoexposureduration.md)
- [autoISO](avfoundation/avcapturedevice/autoiso.md)
- [autoLensAperture](avfoundation/avcapturedevice/autolensaperture.md)
- [currentLensAperture](avfoundation/avcapturedevice/currentlensaperture.md)
- [exposureDuration](avfoundation/avcapturedevice/exposureduration.md)
- [iso](avfoundation/avcapturedevice/iso.md)
- [lensAperture](avfoundation/avcapturedevice/lensaperture.md)
- [activeMaxExposureDuration](avfoundation/avcapturedevice/activemaxexposureduration.md)
- [automaticallyAdjustsExposureDuration](avfoundation/avcapturedevice/automaticallyadjustsexposureduration.md)
- [automaticallyAdjustsISO](avfoundation/avcapturedevice/automaticallyadjustsiso.md)
- [automaticallyAdjustsLensAperture](avfoundation/avcapturedevice/automaticallyadjustslensaperture.md)
- [autoExposureLensApertureRateLimit](avfoundation/avcapturedevice/autoexposurelensapertureratelimit.md)
