Project link

function

  • UI appearance support light/dark/automatic/custom
  • Supports multiple/mixed content selection
  • Supported media types:
  • Photo
  • GIF
  • Live Photo
  • Video
  • Supported local resource types:
  • Photo
  • Video
  • GIF
  • Supported network resource types:
  • Photo
  • Video
  • Support for downloading resources from iCloud
  • Support gesture return
  • Support for sliding selection
  • Edit pictures (support GIFs, network resources)
  • graffiti
  • stickers
  • The text
  • tailoring
  • Mosaic
  • A filter
  • Edit video (support network resources)
  • The music
  • tailoring
  • Photo album Display mode
  • A separate list
  • Popup window
  • Multi-platform support
  • iOS
  • iPadOS
  • Internationalization support
  • English (en)
  • Simplified Chinese (zh-hans)
  • Traditional Chinese (zh-hant)
  • Japanese (ja)
  • Korean (ko)
  • Thai (th)
  • Bahasa Indonesia (id)
  • Custom language (Custom)

requirements

  • IOS 10.0 +
  • Xcode 12.0 +
  • Swift 5.3 +

The installation

Swift Package Manager

⚠️ Requires Xcode 12.0 or later to support the addition of resource files/localization files.

dependencies: [
    .package(url: "https://github.com/SilenceLove/HXPHPicker.git", .upToNextMajor(from: 1.1.7 "")))Copy the code

CocoaPods

Add the following to your Podfile and perform a dependency update.

pod 'HXPHPicker'
Copy the code

Carthage

Add the following to the Cartfile and perform a dependency update.

github "SilenceLove/HXPHPicker"
Copy the code

Method of use

We provide more detailed instructions in the Wiki.

The preparatory work

Add the following keys to your info.plist as needed:

Key note
NSPhotoLibraryUsageDescription Allow access to albums
NSPhotoLibraryAddUsageDescription Allows to save pictures to albums
PHPhotoLibraryPreventAutomaticLimitedAccessAlert Set toYESIOS 14+ to disable the automatic popup to add more photos popup (Limited function, can be triggered by the user actively, improve user experience)
NSCameraUsageDescription Cameras allowed
NSMicrophoneUsageDescription Microphone allowed

Quick learning

import HXPHPicker

class ViewController: UIViewController {

    func presentPickerController(a) {
        // Set the configuration consistent with the wechat theme
        let config = PhotoTools.getWXPickerConfig()
        let pickerController = PhotoPickerController.init(picker: config)
        pickerController.pickerDelegate = self
        // An array of PhotoAsset objects corresponding to the currently selected resource
        pickerController.selectedAssetArray = selectedAssets 
        // Select the original image
        pickerController.isOriginal = isOriginal
        present(pickerController, animated: true, completion: nil)}}extension ViewController: PhotoPickerControllerDelegate {
    
    /// Call after the selection is complete
    /// - Parameters:
    /// -pickerController: corresponding PhotoPickerController
    /// -result: the result of the selection
    /// photoAssets Array of selected resources
    /// result. IsOriginal Specifies whether to select the original image
    func pickerController(_ pickerController: PhotoPickerController.didFinishSelection result: PickerResult) {
        result.getImage { (image, photoAsset, index) in
            if let image = image {
                print("success", image)
            }else {
                print("failed")
            }
        } completionHandler: { (images) in
            print(images)
        }
    }
    
    /// called when you click cancel
    /// -parameter pickerController: PhotoPickerController
    func pickerController(didCancel pickerController: PhotoPickerController){}}Copy the code

Update log

version Release time Xcode Swift iOS
v1.1.7 2021-08-06 12.5.1 5.3 10.0 +
v1.1.6 2021-08-02 12.5.1 5.3 10.0 +
v1.1.5 2021-07-28 12.5.1 5.3 10.0 +
v1.1.4 2021-07-16 12.5.1 5.3 10.0 +
v1.1.3 2021-07-14 12.5.1 5.3 10.0 +

The copyright agreement

HXPHPicker is distributed and used based on the MIT protocol. See the protocol file for more information.