Created
January 29, 2016 12:20
-
-
Save tdtsh/7af1512ab6c3b828d334 to your computer and use it in GitHub Desktop.
Swift2 でトーチをオンにする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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