标签:catch return == default send try cte lse div
func lightBtnAction(sender: UIButton){
let device = AVCaptureDevice.default(for:.video)
if device == nil {
sender.isEnabled = false
return
}
if device?.torchMode == .off{
do {
try device?.lockForConfiguration()
} catch {
return
}
device?.torchMode = .on
device?.unlockForConfiguration()
sender.isSelected = true
}else {
do {
try device?.lockForConfiguration()
} catch {
return
}
device?.torchMode = .off
device?.unlockForConfiguration()
sender.isSelected = false
}
}
标签:catch return == default send try cte lse div
原文地址:https://www.cnblogs.com/kimiyo/p/9487860.html