Git Product home page Git Product logo

hxphpicker's Introduction

HXPHPicker

功能

  • UI 外观支持浅色/深色/自动/自定义
  • 支持多选/混合内容选择
  • 支持的媒体类型:
    • Photo
    • GIF
    • Live Photo
    • Video
  • 支持的本地资源类型:
    • Photo
    • Video
    • GIF
    • Live Photo
  • 支持的网络资源类型:
    • Photo
    • Video
  • 支持下载iCloud上的资源
  • 支持手势返回
  • 支持滑动选择
  • 编辑图片(支持动图、网络资源)
    • 涂鸦
    • 贴纸
    • 文字
    • 裁剪
    • 马赛克
  • 编辑视频(支持网络资源)
    • 裁剪
  • 相册展现方式
    • 单独列表
    • 弹窗
  • 多平台支持
    • iOS
    • iPadOS
  • 国际化支持
    • 英文 (en)
    • 简体中文 (zh-Hans)
    • 繁体中文 (zh-Hant)
    • 日语 (ja)
    • 韩语 (ko)
    • 泰语 (th)
    • 印尼语 (id)
    • 自定义语言 (custom)
    • 更多支持... (欢迎PR)

要求

  • iOS 10.0+
  • Xcode 12.0+
  • Swift 5.3+

安装

⚠️ 需要 Xcode 12.0 及以上版本来支持资源文件/本地化文件的添加。

dependencies: [
    .package(url: "https://github.com/SilenceLove/HXPHPicker.git", .upToNextMajor(from: "1.1.1"))
]

将下面内容添加到 Podfile,并执行依赖更新。

pod 'HXPHPicker'

将下面内容添加到 Cartfile,并执行依赖更新。

github "SilenceLove/HXPHPicker"

使用方法

准备工作

按需在你的 Info.plist 中添加以下键值:

Key 备注
NSPhotoLibraryUsageDescription 允许访问相册
NSPhotoLibraryAddUsageDescription 允许保存图片至相册
PHPhotoLibraryPreventAutomaticLimitedAccessAlert 设置为 YES iOS 14+ 以禁用自动弹出添加更多照片的弹框(已适配 Limited 功能,可由用户主动触发,提升用户体验)
NSCameraUsageDescription 允许使用相机
NSMicrophoneUsageDescription 允许使用麦克风

快速上手

import HXPHPicker

class ViewController: UIViewController {

    func presentPickerController() {
        // 设置与微信主题一致的配置
        let config = PhotoTools.getWXPickerConfig()
        let pickerController = PhotoPickerController.init(picker: config)
        pickerController.pickerDelegate = self
        // 当前被选择的资源对应的 PhotoAsset 对象数组
        pickerController.selectedAssetArray = selectedAssets 
        // 是否选中原图
        pickerController.isOriginal = isOriginal
        present(pickerController, animated: true, completion: nil)
    }
}

extension ViewController: PhotoPickerControllerDelegate {
    
    /// 选择完成之后调用
    /// - Parameters:
    ///   - pickerController: 对应的 PhotoPickerController
    ///   - result: 选择的结果
    ///     result.photoAssets  选择的资源数组
    ///     result.isOriginal   是否选中原图
    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)
        }
    }
    
    /// 点击取消时调用
    /// - Parameter pickerController: 对应的 PhotoPickerController
    func pickerController(didCancel pickerController: PhotoPickerController) {
        
    }
}

更新日志

版本 发布时间 Xcode Swift iOS
v1.1.1 2021-06-17 12.2 5.3 10.0+
v1.1.0 2021-06-08 12.2 5.3 10.0+
v1.0.9 2021-06-04 12.2 5.3 10.0+
v1.0.8 2021-05-20 12.2 5.3 9.0+
v1.0.7 2021-05-17 12.2 5.3 9.0+

版权协议

HXPHPicker 基于 MIT 协议进行分发和使用,更多信息参见协议文件

hxphpicker's People

Contributors

silencelove avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.