AbraGallery
是一个用于图片和视频选择的库。它还提供视频录制功能。
GalleryController
是主入口点,只需实例化并设置代理即可
let gallery = GalleryController()
gallery.delegate2 = self
present(gallery, animated: true, completion: nil)
GalleryControllerDelegate2
需要您实现一些代理方法,以便与GalleryController
交互
public protocol GalleryControllerDelegate2: class {
func galleryController(_ controller: GalleryController, requestLightbox images: [UIImage])
func galleryControllerDidCancel(_ controller: GalleryController)
func galleryController(_ controller: GalleryController, didSelectAssets assets: [PHAsset])
}
Gallery
为您处理权限。它会在首次启动时检查并请求照片和相机使用权限。从iOS 10开始,我们需要在Plist文件中明确声明使用描述
<key>NSCameraUsageDescription</key>
<string>This app requires access to camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to photo library</string>
您可以通过配置Gallery.Config.Permission.shouldCheckPermission = false
禁用权限流程
在Config
结构体中有很多定制点。例如
Config.Permission.image = UIImage(named: ImageList.Gallery.cameraIcon)
Config.Font.Text.bold = UIFont(name: FontList.OpenSans.bold, size: 14)!
Config.Camera.recordLocation = true
Config.Camera.recordMode = .video // to enable video recording.
Config.VideoRecording.maxBytesCount = 1024 // to set the maximum size of video.
Config.VideoRecording.maxLengthInSeconds = .video // to set the max length of video.
Config.Selection.mode = [.photo, .camera, .video] // to enable/disable Photo, Camera and Video tabs.
Config.SessionPreset.quality = AVCaptureSessionPresetHigh // to define the quality of recorded video.
... and many many more at Config file.
通过CocoaPods获取AbraGallery
。要安装它,只需将以下行添加到Podfile中:
pod 'AbraGallery'
AbraGallery
也可以手动安装。只需下载并将您的项目中的Sources
文件夹拖入即可。
OpenSooq, [email protected], [email protected]
Abra Gallery是在Gallery项目之上构建的。
我们非常欢迎您向AbraGallery
做出贡献,有关更多信息,请查看CONTRIBUTING文件。
AbraGallery
可在MIT许可下获得。有关更多信息,请查看LICENSE文件。