DDPerspectiveTransform
图像变换扭曲
安装
CocoaPods
要使用 CocoaPods 安装 DDPerspectiveTransform
,请将以下行添加到 Podfile 中:
pod 'DDPerspectiveTransform'
手动安装
将 DDPerspectiveTransform
文件夹添加到您的 Xcode 项目中。
用法
请查看示例 Xcode 项目。
基本设置
创建DDPerspectiveTransformViewController
实例,并设置image
和delegate
变量。推送/显示它。
let cropViewController = DDPerspectiveTransformViewController()
cropViewController.delegate = self
cropViewController.image = image
navigationController?.pushViewController(cropViewController, animated: true)
填充数据
实现以下delegate
方法
func perspectiveTransformingDidFinish(controller: DDPerspectiveTransformViewController, croppedImage: UIImage)
func perspectiveTransformingDidCancel(controller: DDPerspectiveTransformViewController)
自定义
weak var delegate: DDPerspectiveTransformProtocol?
var image: UIImage? // The image for cropping
var padding: CGFloat? // Minimum padding value for all sides
var paddingWidth: CGFloat? // Minimum padding value for left and right sides
var paddingHeight: CGFloat? // Minimum padding value for top and bottom sides
var boxLineColor: UIColor? // The color of box lines
var boxLineWidth: CGFloat? // The width of box lines
var pointSize: CGSize? // The size of checkpoint
var pointColor: UIColor? // The color of checkpoint
var pointImage: UIImage? // The image of checkpoint
func cropAction()
func cancelAction()
要求
- iOS 8.2
- Xcode 10, Swift 4.2
许可证
DDPerspectiveTransform
遵从MIT许可证。有关更多信息,请参阅LICENSE文件。