ImagePickerSheetController 0.9.3

ImagePickerSheetController 0.9.3

测试测试
Lang语言 SwiftSwift
许可 MIT
发布最后发布2016年9月
SPM支持 SPM

Laurin Brandner 维护。




ImagePickerSheetController

关于

ImagePickerSheetController 是一个组件,它复制了 iMessage 中自定义的照片动作表。它与 UIAlertController 非常相似,这使得它的使用简单而简洁。

Screenshot

使用

ImagePickerSheetController 在其使用上类似于 UIAlertController

示例

let controller = ImagePickerSheetController(mediaType: .ImageAndVideo)
controller.addAction(ImagePickerAction(title: NSLocalizedString("Take Photo Or Video", comment: "Action Title"), secondaryTitle: NSLocalizedString("Add comment", comment: "Action Title"), handler: { _ in
    presentImagePickerController(.Camera)
}, secondaryHandler: { _, numberOfPhotos in
    println("Comment \(numberOfPhotos) photos")
}))
controller.addAction(ImagePickerAction(title: NSLocalizedString("Photo Library", comment: "Action Title"), secondaryTitle: { NSString.localizedStringWithFormat(NSLocalizedString("ImagePickerSheet.button1.Send %lu Photo", comment: "Action Title"), $0) as String}, handler: { _ in
    presentImagePickerController(.PhotoLibrary)
}, secondaryHandler: { _, numberOfPhotos in
    println("Send \(controller.selectedImageAssets)")
}))
controller.addAction(ImagePickerAction(title: NSLocalizedString("Cancel", comment: "Action Title"), style: .Cancel, handler: { _ in
    println("Cancelled")
}))

presentViewController(controller, animated: true, completion: nil)

建议使用 stringsdict 来轻松地在任何语言中翻译复数形式。

要求

ImagePickerSheetController 使用 Swift 编写,并链接到 Photos.framework。因此,需要 iOS 8 或更高版本。

作者

我是 Laurin Brandner,我在 Twitter 上。

许可

ImagePickerSheetController 在 MIT 许可证 下许可。