SMDImagePicker 0.1.1

SMDImagePicker 0.1.1

测试测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2017年10月
SwiftSwift版本4.0
SPM支持SPM

gajjartejas 维护。




SMDImagePicker




基于 Clouser 的 UIImagePickerController 包装器,用 Swift 实现。


演示

在您的控制台执行 pod try SMDImagePicker 并运行项目以尝试演示。
要安装 CocoaPods,请在控制台中运行 sudo gem install cocoapods

安装📱

此分支支持 Swift 4。

源文件

在您的项目中使用 SMDImagePicker 的常规方法是通过嵌入式框架。有两种方法,使用源代码。

添加源代码

  1. 下载最新的代码版本 here
  2. 解压缩下载文件,将 SMDImagePicker 文件夹复制到您的项目文件夹中

通过直接添加或使用子模块获取源代码后,执行以下步骤

  • 打开 SMDImagePicker 文件夹,并将 SMDImagePicker.xcodeproj 拖放至您的应用程序项目文件导航器的应用程序项目下。
  • 在 Xcode 中,通过点击蓝色的项目图标,然后选择侧边栏中“Targets”下的应用程序目标,进入目标配置窗口。
  • 在窗口顶部的选项卡栏中打开“构建阶段”面板,展开“目标依赖”组,通过点击 + ,将 SMDImagePicker.framework 添加到弹出窗口中的 SMDImagePicker 图标下。同样,您也可以在“通用”选项卡的“嵌入式二进制文件”下添加 SMDImagePicker.framework

基本用法

import SMDImagePicker
import MobileCoreServices

let imagePicker = SMDImagePicker()

//For Gallary Images
//Optional
let photoGallaryOptions = SMDImagePicker.PhotoGallaryOptions(allowsEditing: true,
                                                             mediaTypes: [kUTTypeImage as String])
imagePicker.configure(photoGallaryOptions)
imagePicker.choose(media: .choosePhoto, presentFrom: self) { (media, status) in
    if status == .success {
        //You will get media?.editedImage or media?.originalImage if cropping is disabled.
    } else {
        //See example for error handling
}

//For Image Capture From Camera 
//Optional
let options =  SMDImagePicker.PhotoCaptureOptions(allowsEditing: true,
                                                  cameraDevice: .rear,
                                                  mediaTypes: [kUTTypeImage as String],
                                                  flashMode: .auto)
imagePicker.configure(options)
imagePicker.capture(media: .takePhoto, presentFrom: self) { (media, status) in
    if status == .success {
        //You will get media?.editedImage or media?.originalImage if cropping is disabled.
    } else {
        //See example for error handling
    }
}

//For Gallary Video
//Optional
let options = SMDImagePicker.VideoGallaryOptions(allowsEditing: false,
                                                             mediaTypes: [kUTTypeMovie as String],
                                                             maximumDuration: 2*60, //Duration 2 Minutes
                                                             quality: UIImagePickerControllerQualityType.typeMedium)
imagePicker.configure(photoGallaryOptions)
imagePicker.choose(media: .chooseVideo, presentFrom: self) { (media, status) in
    if status == .success {
        //Here you will get media?.mediaURL for video
        //For Video thumb image?.videoThumb
    } else {
        //See example for error handling
    }

//For Record Video
//Optional
let options = SMDImagePicker.VideoRecorderOptions(allowsEditing: true,
                                                  cameraDevice: .rear,
                                                  maximumDuration: 2*60, //Duration 2 Minutes
                                                  quality: .typeHigh,
                                                  flashMode: .auto)

imagePicker.configure(options)
imagePicker.capture(media: .takeVideo, presentFrom: self) { (media, status) in
    if status == .success {
        //Here you will get media?.mediaURL for video
        //For Video thumb image?.videoThumb
    } else {
       //See example for error handling
    }