Instance Method

setTorchModeOnWithLevel:error:

Sets the illumination level when in torch mode.

Declaration

- (BOOL)setTorchModeOnWithLevel:(float)torchLevel error:(NSError * _Nullable *)outError;

Parameters

torchLevel

The new torch mode level. This value must be a floating-point number between 0.0 and 1.0. To set the torch mode level to the currently available maximum, specify the constant AVCaptureMaxAvailableTorchLevel for this parameter.

outError

On input, a pointer to an error object. If an error occurs, this method assigns an error object to the pointer with information about what happened.

Return Value

YES if the torch mode level was set or NO if it was not.

Discussion

This method sets the torch mode to AVCaptureTorchModeOn and sets the level to the specified value. If the device does not support this mode or if you specify a value for torchLevel that is outside the accepted range, this method raises an exception. If the torch value is within the accepted range but greater than the currently supported maximum—perhaps because the device is overheating—this method returns NO.

Before changing the value of this property, you must call lockForConfiguration: to acquire exclusive access to the device’s configuration properties. Otherwise, calling this method raises an exception. When you finish configuring the device, call unlockForConfiguration to release the lock and allow other devices to configure the settings.

See Also

Managing Torch Settings

hasTorch

A Boolean value that specifies whether the capture device has a torch.

torchAvailable

Indicates whether the torch is currently available for use.

torchActive

A Boolean value indicating whether the device’s torch is currently active.

torchLevel

The current torch brightness level.

AVCaptureTorchMode

Constants to specify the capture device’s torch mode.

torchMode

The current torch mode.

- isTorchModeSupported:

Returns a Boolean value that indicates whether the device supports the specified torch mode.