测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布日期最后发布 | 2017年11月 |
SwiftSwift版本 | 4.0 |
SPM支持SPM | ✗ |
由 Adrian Apodaca 维护。
依赖 | |
ByvUtils | ~> 1.1 |
TOCropViewController | = 2.3.4 |
ByvImagePicker 是一个 NSObject 类,可以以三种不同的方式呈现动作表来选择 UIImagePickerController 源类型,并让用户使用 TOCropViewController 编辑图片。
仅显示选择器
@IBAction func pickImage(_ sender: UIButton) {
if picker == nil {
picker = ByvImagePicker()
}
let from = ByvFrom(controller: self, from:sender.frame, inView:self.view, arrowDirections:.any)
picker!.getImage(from: from, completion: { image in
self.imageView.image = image
})
}
选择可编辑的图片
@IBAction func pickAndEdit(_ sender: UIButton) {
if picker == nil {
picker = ByvImagePicker()
}
let from = ByvFrom(controller: self, from:sender.frame, inView:self.view, arrowDirections:.any)
picker!.getImage(from: from, editable:true, completion: { image in
self.imageView.image = image
})
}
以强制宽高比选择图片
@IBAction func pickAndCrop(_ sender: UIButton) {
if picker == nil {
picker = ByvImagePicker()
}
let from = ByvFrom(controller: self, from:sender.frame, inView:self.view, arrowDirections:.any)
picker!.getFixedImage(from: from, customAspectRatio: imageView.bounds.size, completion: { image in
self.imageView.image = image
})
}
选择圆形图片
@IBAction func pickProfile(_ sender: UIButton) {
if picker == nil {
picker = ByvImagePicker()
}
let from = ByvFrom(controller: self, from:sender.frame, inView:self.view, arrowDirections:.any)
picker!.getCircularImage(from: from, completion: { image in
self.profileImage.image = image
})
}
要运行示例项目,请克隆仓库,然后首先从示例目录运行 pod install
ByvImagePicker 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中
作者
pod "ByvImagePicker"
ByvImagePicker 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。
CocoaPods 是由以下人员开发的项目