Skip to content

Instantly share code, notes, and snippets.

@tdtsh
Created January 29, 2016 12:20
Show Gist options
  • Save tdtsh/7af1512ab6c3b828d334 to your computer and use it in GitHub Desktop.
Save tdtsh/7af1512ab6c3b828d334 to your computer and use it in GitHub Desktop.
Swift2 でトーチをオンにする
let devices = AVCaptureDevice.devices()
for capDevice in devices {
if capDevice.position == AVCaptureDevicePosition.Back {
avDevice = capDevice as? AVCaptureDevice
}
}
// トーチオン
if avDevice.hasTorch
do {
try avDevice.lockForConfiguration()
avDevice.torchMode = AVCaptureTorchMode.On
avDevice.unlockForConfiguration()
} catch let error as NSError {
print(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment