<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 17.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVCaptureDevice/setTorchModeOn(level:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVCaptureDevice(im)setTorchModeOnWithLevel:error:"
  },
  "title" : "setTorchModeOn(level:)"
}
-->

# setTorchModeOn(level:)

Sets the illumination level when in torch mode.

```
func setTorchModeOn(level torchLevel: Float) throws
```

## 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 [`maxAvailableTorchLevel`](/documentation/AVFoundation/AVCaptureDevice/maxAvailableTorchLevel) for this parameter.

## Discussion

This method sets the torch mode to [`AVCaptureDevice.TorchMode.on`](/documentation/AVFoundation/AVCaptureDevice/TorchMode-swift.enum/on) and sets the level to the specified value. If the device doesn’t support this mode or if you specify a value for `torchLevel` that’s 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 <doc://com.apple.documentation/documentation/Swift/false>.

Before changing the value of this property, you must call [`lockForConfiguration()`](/documentation/AVFoundation/AVCaptureDevice/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()`](/documentation/AVFoundation/AVCaptureDevice/unlockForConfiguration()) to release the lock and allow other devices to configure the settings.

---

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)