📷 +🗺 +⚡️ = CamMap
CamMap 是一个 Swift 库,帮助应用程序同时拍照和抓取位置。
🚀
功能- 捕获 JPEG 图片
- 尽可能快地使用当前位置。
- 使用浮动的钉子来更好地选择坐标。轻触以保存位置。
- 在地图内拖拽和放置钉子。
- 将照片存储在设备中。提供可配置的标志以将其关闭。
- 优雅地处理横竖屏。
💻
安装CocoaPods
使用在 Podfile
中添加 pod 'CamMap'
并运行 pod install
。同时将 use_frameworks!
添加到 Podfile
use_frameworks!
pod 'CamMap'
使用
首先导入它
import CamMap
然后实现委托协议
extension YouViewController: CamMapDelegate {
func camMapDidComplete(images: [UIImage], location: CLLocationCoordinate2D?) {
// This method gets called if the user took at least one pic
}
func camMapDidCancel() {
// Or this gets called if the user cancelled the action
}
func camMapHadFailure(error: CamMapError) {
// Is called when there's a non recoverall issue with the camera or location maanger
}
func camMapPermissionFailure(type: PermType, details: String) {
// Gets call if there is a missing permission
}
}
然后在 YouViewController 的一个方法内呈现视图控制器
let vc = CamMapViewController()
vc.delegate = self
present(vc, animated: true, completion: nil)
权限
您需要将以下元素添加到您的Info.plist文件中,否则应用将会因相关消息而崩溃。
- NSLocationWhenInUseUsageDescription
- NSCameraUsageDescription
- NSPhotoLibraryAddUsageDescription
代码示例
您可以在本repo中找到一个简单的示例。要尝试它,请先克隆它,然后执行
cd Examples/SimpleCamMapExample/
pod install
open SimpleCamMapExample.xcworkspace
🏁
路线图- 更好的操作按钮
- 显示已拍摄的图片数量
- 在一张照片被添加后能够取消/关闭控制器
- 自定义地图和相机大小
- 能够删除选中的照片
- 更好的权限处理
作者
Humber Aquino [email protected] @goku2
许可协议
CamMap遵循MIT许可协议发布。详情请见LICENSE。