ImagePickerCoordinator
基于TOCropViewController和ImagePicker的另一个图片选择器协调器
如何使用
图片选择器使用很简单,可以缩减到4行代码!
注意:一定要保持对协调器的强引用,以避免过早释放协调器
...
var imagePickerCoordinator:ImagePickerCoordinator
...
imagePickerCoordinator = ImagePickerCoordinator(fromController: .topMost)
imagePickerCoordinator.delegate = self
imagePickerCoordinator.start()
...
配置
您可以配置协调器的一些行为方式。
- 您可以像这样预选一个图片:
imagePickerCoordinator.selectedImage = myPreSelectedImage
- 如有需要,移除裁剪或更改样式。
imagePickerCoordinator.cropStyle = .circular
imagePickerCoordinator.cropStyle = nil // Removes the cropping flow at the end of the image selection
- 避免用户从协调器中删除图片
imagePickerCoordinator.canClearSelectedImageIfAny = false
代理
代理可以告诉您图片已被选中、清除或协调器被取消选择时的情况。如果您需要更多的代理方法,可以要求或创建一个Pull Request!
更多
有建议吗?功能?威胁?告诉我吧!