ZLPhotoBrowser

repository·master·Indexed 26 days ago

https://github.com/longitachi/zlphotobrowser

A WeChat-like image picker for iOS 10.0+ that supports selecting photos, videos, GIFs, and Live Photos. It features built-in image and video editing, a custom camera, and support for SwiftUI, iPad multi-window, and landscape mode. Installation is available via CocoaPods, Carthage, Swift Package Manager, or manual integration.

Tokens
1.4K
Snippets
6
Records
11
Agent score
40%

What's inside ZLPhotoBrowser

  1. Overview of ZLPhotoBrowser features

    master

    ZLPhotoBrowser is a WeChat-style image picker for iOS (supporting iOS 10.0+) that provides:

    • Selection Modes: Drag-to-select in preview, slide-to-select in albums, and mixed media support (Image/Gif/LivePhoto/Video).
    • Editing: Built-in image editing (crop, stickers, text, mosaic, filters) and video editing.
    • Custom Camera: WeChat-style camera with support for custom recording durations, resolutions, and flash modes.
    • UI Customization: Support for SwiftUI, iPad multi-window, landscape mode, custom fonts, and dynamic colors (Light/Dark mode).
    • Internationalization: Support for multiple languages including Chinese, English, Japanese, French, German, and more.
  2. Install ZLPhotoBrowser via CocoaPods

    master

    Add ZLPhotoBrowser to your Podfile to integrate it into your Xcode project. Ensure your platform is set to iOS 10.0 or higher and use_frameworks! is enabled.

    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '10.0'
    use_frameworks!
    
    target 'MyApp' do
      # your other pod
      # ...
      pod 'ZLPhotoBrowser'
    end

    Then run:

    $ pod install
  3. Install ZLPhotoBrowser via Swift Package Manager

    master
    1. In Xcode, select File > Add Packages.
    2. Enter https://github.com/longitachi/ZLPhotoBrowser.git in the Choose Package Repository dialog.
    3. Set the version resolving rule to Up to Next Major with 5.0.0 as the earliest version.
    4. Add the ZLPhotoBrowser library to your app target.
  4. Configure Info.plist permissions and localization

    master

    To ensure proper functionality, you must configure your Info.plist with the following keys:

    Localization Support

    To enable multi-language support (otherwise album names default to English), add:

    • CFBundleAllowMixedLocalizations (set to YES or add as Localized resources can be mixed)

    Privacy Permissions

    You must provide usage descriptions for the following keys:

    • NSPhotoLibraryUsageDescription (Privacy - Photo Library Usage Description)
    • NSCameraUsageDescription (Privacy - Camera Usage Description)
    • NSMicrophoneUsageDescription (Privacy - Microphone Usage Description)
  5. Install ZLPhotoBrowser via CocoaPods, Carthage, or SPM

    master

    You can install ZLPhotoBrowser using several dependency managers:

    CocoaPods

    Add the following to your Podfile and run pod install:

    pod 'ZLPhotoBrowser'

    Note: If the latest version is not found, run pod repo update first.

    Carthage

    Add the following to your Cartfile and run $ carthage update:

    github "longitachi/ZLPhotoBrowser"

    Note: If you encounter architecture errors, rebuild using the --use-xcframeworks flag.

    Swift Package Manager (SPM)

    1. In Xcode, select File > Swift Packages > Add Package Dependency.
    2. Enter the repository URL: https://github.com/longitachi/ZLPhotoBrowser.git.
    3. Specify the version (minimum version required is 5.0.0).

    Manual Installation

    Drag the Sources folder directly into your Xcode project.

    pod 'ZLPhotoBrowser'
  6. Configure Info.plist for ZLPhotoBrowser

    master

    To support multiple languages (so album names are localized) and to access system resources, you must add the following keys to your Info.plist:

    • Localized resources can be mixed: Set to YES
    • Privacy - Photo Library Usage Description
    • Privacy - Camera Usage Description
    • Privacy - Microphone Usage Description
  7. Enter photo library directly

    master

    Use ZLPhotoPreviewSheet to skip the preview and go directly to the album selection interface.

    let picker = ZLPhotoPreviewSheet()
    picker.selectImageBlock = { [weak self] results, isOriginal in
        // your code
    }
    picker.showPhotoLibrary(sender: self)
  8. Use ZLPhotoPicker for Library Selection

    master

    Initialize ZLPhotoPicker and set the selectImageBlock to handle the results. Use showPhotoLibrary(sender:) to present the photo library selection interface.

    let picker = ZLPhotoPicker()
    picker.selectImageBlock = { [weak self] results, isOriginal in
        // your code
    }
    picker.showPhotoLibrary(sender: self)
  9. Use ZLPhotoPicker for Preview Selection

    master

    Initialize ZLPhotoPicker and set the selectImageBlock to handle the results. Use showPreview(animate:sender:) to present the preview selection interface.

    let picker = ZLPhotoPicker()
    picker.selectImageBlock = { [weak self] results, isOriginal in
        // your code
    }
    picker.showPreview(animate: true, sender: self)
  10. Perform quick photo selection

    master

    Use ZLPhotoPicker to present a picker that starts with a preview interface. The selectImageBlock is called when the user finishes selecting images.

    let picker = ZLPhotoPicker()
    picker.selectImageBlock = { [weak self] results, isOriginal in
        // your code
    }
    picker.showPreview(animate: true, sender: self)