测试测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最新发布 | 2017年10月 |
SwiftSwift版本 | 4.0 |
SPM支持SPM | ✗ |
由 gajjartejas 维护。
基于 Clouser 的 UIImagePickerController 包装器,用 Swift 实现。
在您的控制台执行 pod try SMDImagePicker
并运行项目以尝试演示。
要安装 CocoaPods,请在控制台中运行 sudo gem install cocoapods
此分支支持 Swift 4。
在您的项目中使用 SMDImagePicker 的常规方法是通过嵌入式框架。有两种方法,使用源代码。
添加源代码
SMDImagePicker
文件夹复制到您的项目文件夹中通过直接添加或使用子模块获取源代码后,执行以下步骤
SMDImagePicker
文件夹,并将 SMDImagePicker.xcodeproj
拖放至您的应用程序项目文件导航器的应用程序项目下。+
,将 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
}