Fusuma
Fusuma 是一个 Swift 库,它提供 Instagram 风格的照片浏览器和一些相机功能,只需几行代码即可实现。
您可以使用 Fusuma 替代 UIImagePickerController。它还具有拍摄方形照片的功能。
预览
图片
功能
- UIImagePickerController 的替代方案
- 从相册裁剪图片
- 使用 AVFoundation 拍摄方形照片和视频
- 闪光灯:开 & 关
- 相机模式:前置 & 后置
- 视频模式
- 颜色完全可定制
这些功能只需几行代码就可以实现!
安装
手动安装
下载并将“Classes”文件夹拖入您的Xcode项目。
CocoaPods
使用在您的Podfile
中添加pod 'Fusuma'
并运行pod install
。同时,在Podfile
中添加use_frameworks!
。
use_frameworks!
pod 'Fusuma'
Swift 3
最新版本支持Swift 4.2。如果您仍在使用Swift 3,可以按照以下步骤安装Fusuma
pod 'Fusuma', github: '[email protected]:ytakzk/Fusuma.git', branch: 'swift-3'
Fusuma用法
导入Fusuma import Fusuma
,然后在除viewDidLoad
之外的其他函数中使用以下代码,并将FusumaDelegate赋给视图控制器。
let fusuma = FusumaViewController()
fusuma.delegate = self
fusuma.availableModes = [FusumaMode.library, FusumaMode.camera, FusumaMode.video] // Add .video capturing mode to the default .library and .camera modes
fusuma.cropHeightRatio = 0.6 // Height-to-width ratio. The default value is 1, which means a squared-size photo.
fusuma.allowMultipleSelection = true // You can select multiple photos from the camera roll. The default value is false.
self.present(fusuma, animated: true, completion: nil)
代理方法
// Return the image which is selected from camera roll or is taken via the camera.
func fusumaImageSelected(_ image: UIImage, source: FusumaMode) {
print("Image selected")
}
// Return the image but called after is dismissed.
func fusumaDismissedWithImage(image: UIImage, source: FusumaMode) {
print("Called just after FusumaViewController is dismissed.")
}
func fusumaVideoCompleted(withFileURL fileURL: URL) {
print("Called just after a video has been selected.")
}
// When camera roll is not authorized, this method is called.
func fusumaCameraRollUnauthorized() {
print("Camera roll unauthorized")
}
// Return selected images when you allow to select multiple photos.
func fusumaMultipleImageSelected(_ images: [UIImage], source: FusumaMode) {
}
// Return an image and the detailed information.
func fusumaImageSelected(_ image: UIImage, source: FusumaMode, metaData: ImageMetadata) {
}
如何自定义
let fusuma = FusumaViewController()
fusuma.delegate = self
// ...
fusumaCameraRollTitle = "CustomizeCameraRollTitle"
fusumaCameraTitle = "CustomizeCameraTitle" // Camera Title
fusumaTintColor: UIColor // tint color
// ...
self.present(fusuma, animated: true, completion: nil)
属性
Fusuma for Xamarin
Cheesebaron 为 Xamarin 开发了 Chafu。
https://github.com/Cheesebaron/Chafu
作者
ytakzk
https://ytakzk.me
捐赠
欢迎通过比特币 3Ps8tBgz4qn6zVUr5D1wcYrrzYjMgEugqv 支持您。
许可
Fusuma 使用 MIT 许可发布。
请参阅 LICENSE 了解详细信息。