英文 | 简体中文
ZLPhotoBrowser是一个类似于微信的照片选择器。支持选择普通照片、视频、gif和livePhoto。支持编辑图片和裁剪视频。
目录
请参考Wiki查看Swift和OC的详细使用方法。
如果您只想使用图像编辑功能,请切换到ZLImageEditor。
特性
- 横竖屏。
- 两种框架风格。
- 预览选择(支持拖放)。
- 图库选择(支持滑动选择)。
- 图片/Gif/LivePhoto/视频。
- 自定义预览或选择的最大数量,视频的最大和最小可选时长。
- 自定义每行显示的列数。
- 图片编辑器(绘画/裁剪/图片贴纸/文字贴纸/马赛克/滤镜/调整(亮度、对比度和饱和度)),(绘画颜色可以自定义;裁剪比例可以自定义;滤镜效果可以自定义;您可以选择所需的编辑工具)。
- 视频编辑器。
- 自定义相机。
- 多语言。
- 已选择索引。
- 已选择/不可选择状态阴影蒙版。
- 所选照片在底部的缩略图窗格中显示,可拖动和排序。
- 相机的内部照片单元格显示相机捕捉的图片。
- 自定义字体。
- 框架中每个部分的颜色可以自定义(支持动态颜色,可适配光/暗模式)。
- 自定义图片。
若在使用过程中有好的需求和建议,或遇到任何bug,请创建问题,我会及时回复。
需求
- iOS 10.0
- Swift 5.x
- Xcode 12.x
用法
- 预览选择
let ps = ZLPhotoPreviewSheet()
ps.selectImageBlock = { [weak self] results, isOriginal in
// your code
}
ps.showPreview(animate: true, sender: self)
- 库选择
let ps = ZLPhotoPreviewSheet()
ps.selectImageBlock = { [weak self] results, isOriginal in
// your code
}
ps.showPhotoLibrary(sender: self)
- 注意,您需要在应用Info.plist中添加以下键值对
// If you don’t add this key-value pair, multiple languages are not supported, and the album name defaults to English
Localized resources can be mixed YES
Privacy - Photo Library Usage Description
Privacy - Camera Usage Description
Privacy - Microphone Usage Description
变更日志
● 4.4.2
Add:
Preserve the alpha channel of the edited image.
Fix:
Fix a crash caused by UI modification in a sub-thread.
● 4.4.1
Add:
Adapt to RTL.
Fix:
Fix the problem that the image editor does not work properly when the scale of the picture is not 1.
Fixed some UI display issue in the image preview interface.
● 4.4.0
Add:
Limit the maximum number of frames of GIF images to avoid crashes caused by loading too many frames of GIFs, and provide a series of blocks to support custom implementation of GIF image playback.
Modify the UI effect of text input in the image editor.
Support set the default camera position.
...
语言
安装
在项目中使用 ZLPhotoBrowser 有四种方法
- 使用 CocoaPods
- 使用 Carthage
- 使用 Swift 包管理器
- 手动安装(构建框架或嵌入 Xcode 项目)
CocoaPods
要使用 CocoaPods 将 ZLPhotoBrowser 集成到您的 Xcode 项目中,请在 Podfile 中指定一个目标
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target 'MyApp' do
# your other pod
# ...
pod 'ZLPhotoBrowser'
end
然后,运行以下命令
$ pod install
如果找不到最新版本,您可以首先运行
pod repo update
Carthage
为了使用 Carthage 将 ZLPhotoBrowser 集成到您的 Xcode 项目中,请在 Cartfile 中指定它
github "longitachi/ZLPhotoBrowser"
然后,运行以下命令以构建 ZLPhotoBrowser 框架
$ carthage update
如果您收到类似于 Building universal frameworks with common architectures is not possible. The device and simulator slices for "ZLPhotoBrowser" both build for: arm64 Rebuild with --use-xcframeworks to create an xcframework bundle instead.
的错误,请点击这个链接。
Swift 包管理器
- 选择 文件 > Swift 包 > 添加包依赖。在“选择包仓库”对话框中输入 https://github.com/longitachi/ZLPhotoBrowser.git。
- 在下一页中,将版本解析规则指定为“直到下一个主要版本”,最早版本为“4.0.9”。
- 在Xcode检出源代码并解决版本后,您可以选择“ZLPhotoBrowser”库并将其添加到您的应用程序目标中。
支持
- ★ Star 这个仓库。
- 支持以下工具:
或
或
演示效果
- 视频编辑器
- 多语言
- 自定义摄像头