首页 > 编程语言 > 详细

swift 灯光的打开与关闭

时间:2018-08-16 16:12:50      阅读:206      评论:0      收藏:0      [点我收藏+]
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
        }
    }

 

swift 灯光的打开与关闭

原文:https://www.cnblogs.com/kimiyo/p/9487860.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!