Pickle 版本 1.4.0

Pickle 版本 1.4.0

测试测试过
语言语言 SwiftSwift
许可证 Apache-2.0
发布最新版本2019年4月
SPM支持SPM

bcylinJay AngDave 维护。



Pickle 版本 1.4.0

Pickle

Build Status Carthage compatible CocoaPods Compatible Platform Swift 4.2

Carousell图片选择器。

  • 跨专辑进行多图选择
  • 按照所需顺序选择照片
  • 可自定义主题

使用方法

import Pickle

使用方法与UIImagePickerController类似

let picker = ImagePickerController()
picker.delegate = self as? ImagePickerControllerDelegate
present(picker, animated: true, completion: nil)

显示预选图片

let assets: [PHAsset] = []
let picker = ImagePickerController(selectedAssets: assets)

ImagePickerController在显示时会请求访问相册的权限(如果需要)。

委托

ImagePickerControllerDelegate负责关闭图片选择器。所需委托方法

/// Asks the delegate if the image picker should launch camera with certain permission status.
func imagePickerController(_ picker: ImagePickerController, shouldLaunchCameraWithAuthorization status: AVAuthorizationStatus) -> Bool

 /// Tells the delegate that picker has finished launching camera with an array of selected assets
    @objc optional func imagePickerController(_ picker: ImagePickerController, didFinishLaunchingCameraWith assets: [PHAsset])

/// Tells the delegate that the user picked image assets. The delegate is responsible for dismissing the image picker.
func imagePickerController(_ picker: ImagePickerController, didFinishPickingImageAssets assets: [PHAsset])

/// Tells the delegate that the user cancelled the pick operation. The delegate is responsible for dismissing the image picker.
func imagePickerControllerDidCancel(_ picker: ImagePickerController)

外观

使用修改后的Parameters结构或任何遵循ImagePickerConfigurable的类型的结构来自定义外观。

var parameters = Pickle.Parameters()
parameters.allowedSelections = .limit(to: 4)
let picker = ImagePickerController(configuration: parameters)

查看ImagePickerConfigurable.swift以获取完整的可配置属性列表。

相机

UIImagePickerControllersourceType = .camera作为设备上的默认相机。通过提供CameraCompatible类型或闭包来返回已配置的相机控制器实例,从相册启动自定义相机。

let picker = ImagePickerController(
  selectedAssets: [],
  configuration: Pickle.Parameters(),
  cameraType: UIImagePickerController.self
)
let initializer = {
  return UIImagePickerController()
}

let picker = ImagePickerController(
  selectedAssets: [],
  configuration: Pickle.Parameters(),
  camera: initializer
)

此功能将更新selectedAssets属性的新值并更新UI。不会触发任何delegate回调

public func updateSelectedAssets(with assets: [PHAsset]) { }

文档

Pickle参考

https://carousell.github.io/pickle

配置示例

安装CocoaPods

gem install cocoapods

设置开发pods

make bootstrap

要求

Pickle iOS Xcode Swift
>= 1.0.0 8.0+ 8.3.3 Swift 3.1
>= 1.2.0 9.0+ 8.3.3 Swift 3.1
>= 1.3.0 9.0+ 9.2 Swift 4.0

安装

使用 CocoaPods

创建以下规范的 Podfile 并运行 pod install

platform :ios, '9.0'
use_frameworks!

pod 'Pickle'

使用 Carthage

创建以下规范的 Cartfile 并运行 carthage bootstrap。按照 说明 将框架添加到项目中。

github "carousell/pickle"

贡献

感谢您对参与此项目感兴趣。有关更多信息,请查看 CONTRIBUTING 文档。

关于

Carousell

PickleCarousell 创建和维护。帮助我们改进此项目!我们非常希望听到您的 反馈

我们在招聘!了解更多信息,请访问 http://careers.carousell.com/

许可

Pickle 遵循 Apache License 2.0 许可。有关详细信息,请参阅 LICENSE