-
Notifications
You must be signed in to change notification settings - Fork 982
How to use (Swift)
long edited this page Oct 10, 2020
·
28 revisions
在需要使用的地方添加
import ZLPhotoBrowser
该类为框架配置类,可根据自己需要对各个参数进行配置
// example
ZLPhotoConfiguration.default().allowSelectVideo = false
该类为框架各个控件颜色配置类,可根据自己需要进行自定义
// example
ZLPhotoConfiguration.default().themeColorDeploy.thumbnailBgColor = .black
let ps = ZLPhotoPreviewSheet()
ps.selectImageBlock = { [weak self] (images, assets, isOriginal) in
// your code
}
ps.showPreview(animate: true, sender: self)
let ps = ZLPhotoPreviewSheet()
ps.selectImageBlock = { [weak self] (images, assets, isOriginal) in
// your code
}
ps.showPhotoLibrary(sender: self)
let camera = ZLCustomCamera()
camera.takeDoneBlock = { [weak self] (image, videoUrl) in
// your code
}
self.showDetailViewController(camera, sender: nil)
// 设置编辑工具
ZLPhotoConfiguration.default().editImageTools = [.draw, .clip, .mosaic]
// 设置裁剪比例
ZLPhotoConfiguration.default().editImageClipRatios = [.custom, .wh1x1, .wh3x4, .wh16x9, ZLImageClipRatio(title: "1 : 2", whRatio: 1 / 2)]
let editVC = ZLEditImageViewController(image: image)
editVC.editFinishBlock = { [weak self] (image) in
// your code
}
editVC.modalPresentationStyle = .fullScreen
self.showDetailViewController(editVC, sender: nil)
class CustomFilter {
class func filterMethod(image: UIImage) -> UIImage {
// 1.创建滤镜
// 2.对image进行处理
// 3.返回处理后的图片
}
}
ZLPhotoConfiguration.default().filters = [ZLFilter(name: "custom", applier: CustomFilter.filterMethod)]
// 编辑本地视频
let fileUrl = URL(fileURLWithPath: "filePath")
let avAsset = AVAsset(url: fileUrl)
let editVC = ZLEditVideoViewController(avAsset: avAsset, animateDismiss: true)
editVC.editFinishBlock = { (url) in
// your code
}
editVC.modalPresentationStyle = .fullScreen
self.showDetailViewController(editVC, sender: nil)
// 与图片名字保持一致即可
ZLPhotoConfiguration.default().customImageNames = ["zl_btn_selected"]
ZLPhotoConfiguration.default().customLanguageKeyValue = [.previewCamera: "拍照"]
if #available(iOS 13.0, *) {
ZLPhotoConfiguration.default().themeColorDeploy.thumbnailBgColor = UIColor.init(dynamicProvider: { (trait) -> UIColor in
if trait.userInterfaceStyle == .dark {
return .black
} else {
return .white
}
})
}