swift-判断是否已获得相机、相册权限

// 相机权限

func isRightCamera() -> Bool {

    let authStatus = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo)

    return authStatus != .restricted && authStatus != .denied

}


// 相册权限

func isRightPhoto() -> Bool {

    let authStatus = ALAssetsLibrary.authorizationStatus()

    return authStatus != .restricted && authStatus != .denied

}


posted @ 2017-07-05 14:18  brave-sailor  阅读(2255)  评论(0编辑  收藏  举报