swift 相机、相册、定位的权限判断

 

//是否开启相机权限
func IsOpenCamera() -> Bool{
    let authStatus = AVCaptureDevice.authorizationStatus(for: .video)
    return authStatus != .restricted && authStatus != .denied
}

//是否开启相册权限
func IsOpenAlbum() -> Bool{
    let authStatus = PHPhotoLibrary.authorizationStatus()
    return authStatus != .restricted && authStatus != .denied
}

//是否开启定位权限
func IsOpenLocation() -> Bool{
    let authStatus = CLLocationManager.authorizationStatus()
    return authStatus != .restricted && authStatus != .denied
}

 

posted @ 2018-08-16 10:59  milaliu99  Views(2335)  Comments(0)    收藏  举报