CropPickerController
简介
有一个用于裁剪的单张图片选择控制器和一个用于选择各种图片的多图片选择控制器。您可以选择相册,编辑相册时它将自动更新。
CropPickerView
如果您想自定义 UIViewController 或仅显示裁剪视图,请参阅 CropPickerView。
CropPickerController
单一 | 复杂 |
---|---|
![]() |
![]() |
相机 | 进度 |
---|---|
![]() |
![]() |
要求
CropPickerController
使用 Swift 5.0 编写,与 iOS 8.0+ 兼容。
安装
CropPickerController 可以通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中
pod 'CropPickerController'
使用方法
import CropPickerController
let cropPickerController = CropPickerController(.single)
// let cropPickerController = CropPickerController(.complex)
cropPickerController.delegate = self
let navigationController = UINavigationController(rootViewController: cropPickerController)
present(navigationController, animated: true, completion: nil)
初始化
CropPickerController(.single)
CropPickerController(.single, isCamera: true)
CropPickerController(.complex)
CropPickerController(.complex, isCamera: false)
属性
BarButtonItem
cropPickerController.leftBarButtonItem = UIBarButtonItem(title: "Back", style: .plain, target: cropPickerController, action: #selector(cropPickerController.backTap(_:)))
cropPickerController.rightBarButtonItem = UIBarButtonItem(title: "Crop", style: .done, target: cropPickerController, action: #selector(cropPickerController.cropTap(_:)))
颜色
cropPickerController.leftBarButtonItem?.tintColor = .black
cropPickerController.rightBarButtonItem?.tintColor = .black
cropPickerController.titleButton.setTitleColor(.black, for: .normal)
cropPickerController.cameraTintColor = .red
cropPickerController.cameraBackgroundColor = UIColor(white: 0.2, alpha: 1)
cropPickerController.pictureDimColor = UIColor(red: 242/255, green: 121/255, blue: 141/255, alpha: 0.5)
cropPickerController.selectBoxTintColor = .black
cropPickerController.selectBoxLayerColor = .gray
cropPickerController.selectBoxBackgroundColor = .gray
cropPickerController.progressTextColor = .black
cropPickerController.progressColor = .red
cropPickerController.progressTintColor = .blue
cropPickerController.progressBackgroundColor = .white
cropPickerController.cropLineColor = .blue
cropPickerController.imageBackgroundColor = .white
cropPickerController.scrollBackgroundColor = .white
cropPickerController.cropDimBackgroundColor = UIColor(white: 0, alpha: 0.9)
缩放
cropPickerController.scrollMinimumZoomScale = 0.1
cropPickerController.scrollMaximumZoomScale = 12
文本
cropPickerController.permissionGalleryDeniedTitle = "Denied"
cropPickerController.permissionGalleryDeniedMessage = "Denied Gallery"
cropPickerController.permissionCameraDeniedTitle = "Denied"
cropPickerController.permissionCameraDeniedMessage = "Denied Camera"
cropPickerController.permissionActionMoveTitle = "Move~"
cropPickerController.permissionActionCancelTitle = "Cancel!"
选择器
返回和裁剪
#selector(cropPickerController.backTap(_:))
#selector(cropPickerController.cropTap(_:))
代理
class ViewController: UIViewController{
override func viewDidLoad() {
super.viewDidLoad()
let cropPickerController = CropPickerController(.single)
cropPickerController.delegate = self
}
}
// MARK: CropPickerDelegate
extension ViewController: CropPickerDelegate {
func cropPickerBackAction(_ cropPickerController: CropPickerController) {
}
func cropPickerCompleteAction(_ cropPickerController: CropPickerController, images: [UIImage]?, error: Error?) {
}
}
作者
pikachu987, [email protected]
许可协议
CropPickerController 在 MIT 许可协议下可用。更多信息请参阅 LICENSE 文件。