测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年8月 |
SwiftSwift 版本 | 3.1 |
SPM支持 SPM | ✗ |
由 Dark Dong 维护。
从系统相册中选择照片的照片选择器
iOS 8.0, Swift 3.1
下载并将源添加到项目
let picker = PhotoPickerNavigationController.nc
present(picker, animated: true, completion: nil)
let picker = PhotoPickerNavigationController.nc
picker.config.rootTitle = "Root Title"
picker.config.mediaType = .image
present(picker, animated: true, completion: nil)
class ViewController: UIViewController {
func showPicker() {
let picker = PhotoPickerNavigationController.nc
picker.pickerDelegate = self
present(picker, animated: true, completion: nil)
}
}
extension ViewController: PhotoPickerDelegate {
func picker(_ picker: PhotoPickerNavigationController, didSelectAssets assets: [PHAsset]) {
//do what you want
//...
//dismiss picker
picker.dismiss(animated: true, completion: nil)
}
func picker(_ picker: PhotoPickerNavigationController, shouldSelectAsset: PHAsset, selectedAssets: [PHAsset]) -> Bool {
//limit number of selections
if selectedAssets.count >= 2 {
return false
}
return true
}
}
PhotoPicker 在 MIT 许可证下发布。有关详情,请参阅 LICENSE。