github:https://github.com/Darren-che...git
語言:swift 這是一個多圖片選擇的控件,支持圖片多選,縮放,視頻預覽、照片預覽、屏蔽視頻文件、播放視頻文件、屏蔽圖片資源顯示視頻資源、重置選中狀態、預覽、異步下載圖片、視頻文件和圖片文件不能同時選擇、圖片編輯操做(馬賽克,塗鴉)github
pod 'CLImagePickerTool'swift
建議使用下面的方式及時下載最新版
pod 'CLImagePickerTool', :git => 'https://github.com/Darren-che...'數組
1.基本用法,默認相機選擇在內部、圖片多選、支持選擇視頻文件異步
// superVC 當前的控制器 let imagePickTool = CLImagePickersTool() imagePickTool.setupImagePickerWith(MaxImagesCount: 6, superVC: self) { (asset,cutImage) in print("返回的asset數組是\(asset)") }
2.設置相機選擇在外部 imagePickTool.cameraOut = trueide
let imagePickTool = CLImagePickersTool() imagePickTool.cameraOut = true imagePickTool.setupImagePickerWith(MaxImagesCount: 6, superVC: self) { (asset,cutImage) in print("返回的asset數組是\(asset)") }
3.設置只支持照片文件,不支持視頻文件imagePickTool.isHiddenVideo = truespa
let imagePickTool = CLImagePickersTool() imagePickTool.isHiddenVideo = true imagePickTool.setupImagePickerWith(MaxImagesCount: 6, superVC: self) { (asset,cutImage) in }
4.設置圖片單選,屏蔽多選code
let imagePickTool = CLImagePickersTool() imagePickTool.singleImageChooseType = .singlePicture imagePickTool.setupImagePickerWith(MaxImagesCount: 6, superVC: self) { (asset,cutImage) in }
5.單選圖片,選擇完成後進行裁剪操做視頻
let imagePickTool = CLImagePickersTool() imagePickTool.singleImageChooseType = .singlePictureCrop imagePickTool.setupImagePickerWith(MaxImagesCount: 1, superVC: self) { (asset,cutImage) in }
6.視頻文件和圖片文件不能同時選擇對象
let imagePickTool = CLImagePickersTool() imagePickTool.onlyChooseImageOrVideo = true imagePickTool.setupImagePickerWith(MaxImagesCount: 6, superVC: self) { (asset,cutImage) in }
7.設置單選模式下圖片能夠編輯(塗鴉,馬賽克等操做)
let imagePickTool = CLImagePickersTool() imagePickTool.singleImageChooseType = .singlePicture imagePickTool.singleModelImageCanEditor = true imagePickTool.setupImagePickerWith(MaxImagesCount: 6, superVC: self) { (asset,editorImage) in self.img.image = editorImage }
8.只顯示視頻文件,不顯示圖片文件
let imagePickTool = CLImagePickersTool() imagePickTool.isHiddenImage = true imagePickTool.setupImagePickerWith(MaxImagesCount: 6, superVC: self) { (asset,editorImage) in }
1.選擇照片之後在返回的PHAsset對象,在CLPickerTool類中提供了PHAsset轉image的方法,並能夠設置圖片壓縮。
let imageArr = CLImagePickersTool.convertAssetArrToImage(assetArr: asset, scale: 0.2)
該方法是同步方法當選擇圖片較多時可能會等待,咱們能夠提示一個加載框表示正在處理中
2.若是是視頻文件,提供了PHAsset轉AVPlayerItem對象的方法
let Arr = CLImagePickersTool.convertAssetArrToAvPlayerItemArr(assetArr: asset)
3.你會發如今選擇完圖片後提供了2個回調參數 (asset,cutImage) ,在通常狀況下使用asset來轉化本身想要的指定壓縮大小的圖片,而cutImage只有在單選裁剪的狀況纔會返回,其餘狀況返回nil