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

时间:2021-06-11 08:54:49
//是否开启相机权限
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
}