Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to use (Swift)

long edited this pageJul 23, 2025 ·29 revisions

ZLPhotoConfiguration

This class is a configuration class for framework, you can configure each parameter according to your needs.

// exampleZLPhotoConfiguration.default().allowSelectVideo=false

ZLPhotoUIConfiguration

This class is used to configure the framework UI style, including colors, languages, images, etc.

// exampleZLPhotoUIConfiguration.default().themeColor(.black).indexLabelBgColor(.black)

Preview selection

letpicker=ZLPhotoPicker()picker.selectImageBlock={[weak self] results, assets, isOriginalin    // your code}picker.showPreview(animate:true, sender:self)

Library selection

letpicker=ZLPhotoPicker()picker.selectImageBlock={[weak self] results, isOriginalin    // your code}picker.showPhotoLibrary(sender:self)

Use custom camera

ZLPhotoConfiguration.default().cameraConfiguration.allowRecordVideo(false).allowSwitchCamera(false).showFlashSwitch(true)letcamera=ZLCustomCamera()camera.takeDoneBlock={[weak self] image, videoUrlin    // your code}self.showDetailViewController(camera, sender:nil)

Use image editor

// configuration of image editorZLPhotoConfiguration.default().editImageConfiguration.tools([.draw,.clip,.imageSticker,.textSticker,.mosaic,.filter,.adjust]).clipRatios([.custom,.circle,.wh1x1,.wh3x4,.wh16x9,ZLImageClipRatio(title:"1 : 2", whRatio:1/2)])leteditVC=ZLEditImageViewController(image: image)editVC.editFinishBlock={[weak self] imagein    // your code}editVC.modalPresentationStyle=.fullScreenself.showDetailViewController(editVC, sender:nil)
  • About image sticker

You must provide a view that implements ZLImageStickerContainerDelegate.See thisDemo.

@objc public var imageStickerContainerView: (UIView & ZLImageStickerContainerDelegate)? = nil

Customize filter

classCustomFilter{classfunc filterMethod(image:UIImage)->UIImage{        // 1. create filter.        // 2. process the image.        // 3. return the processed picture.}}ZLPhotoConfiguration.default().editImageConfiguration.filters([ZLFilter(name:"custom", applier:CustomFilter.filterMethod)])

Use video editor

// edit local file.letfileUrl=URL(fileURLWithPath:"filePath")letavAsset=AVAsset(url: fileUrl)leteditVC=ZLEditVideoViewController(avAsset: avAsset, animateDismiss:true)editVC.editFinishBlock={ urlin    // your code}editVC.modalPresentationStyle=.fullScreenself.showDetailViewController(editVC, sender:nil)

Customize image resource

// Need to be consistent with the framework image name.ZLPhotoUIConfiguration.default().customImageNames(["zl_btn_selected"])// orZLPhotoUIConfiguration.default().customImageForKey(["zl_btn_selected":UIImage(named:"")])

Customize language

ZLPhotoUIConfiguration.default().customLanguageKeyValue([.previewCamera:"Camera"])

Support light/dark mode

if #available(iOS13.0,*){ZLPhotoUIConfiguration.default().thumbnailBgColor=UIColor.init(dynamicProvider:{ trait->UIColorinif trait.userInterfaceStyle==.dark{return.black}else{return.white}})}

Preview PHAsset, local image, local video, network image, network video together

// Must be one of PHAsset, UIImage and URL, framework will filter others.letdatas:[Any]=[...]letvideoSuffixs=["mp4","mov","avi","rmvb","rm","flv","3gp","wmv","vob","dat","m4v","f4v","mkv"] // and more suffixsletvc=ZLImagePreviewController(datas: datas, index:0, showSelectBtn:true){ url->ZLURLTypeiniflet sf= url.absoluteString.split(separator:".").last, videoSuffixs.contains(String(sf)){return.video}else{return.image}} urlImageLoader:{ url, imageView, progress, loadFinishin    // Demo used Kingfisher.    imageView.kf.setImage(with: url){ receivedSize, totalSizeinletpercent=(CGFloat(receivedSize)/ CGFloat(totalSize))progress(percent)} completionHandler:{ _inloadFinish()}}vc.doneBlock={ datasin    // your code}vc.modalPresentationStyle=.fullScreenself.showDetailViewController(vc, sender:nil)
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp