ImageCropperPOD 0.1.1

ImageCropperPOD 0.1.1

Lucas Santos维护。



  • Lucas Santos

ImageCropperPOD

一个简单的 Swift 图像裁剪工具

轻松裁剪和调整图像大小!

快速示例

import ImageCropperPOD
...
let cropper = ImageCropper()
let croppedImage = cropper.crop(image: originalImage, anchor: .center, percentualWidth: 0.5, percentualHeight: 0.5)
self.imageView.image = croppedImage

使用锚定属性,您可以轻松进行任何类型的裁剪,如上面的图像:alt text

裁剪

第一

创建一个 ImageCropper 对象

let cropper = ImageCropper()

第二

使用 crop 函数进行裁剪,并传递以下参数
图片: 您想要裁剪的 UIImage。
锚点: 裁剪时使用的锚点。可能的五个值是 .topLeft / .topRight / .center / .bottomLeft / .bottomRight。查看示例中的图像,以了解选择每个锚点的影响。
percentualWidth 和 percentualHeight 一个在 0 到 1 之间的数字,表示裁剪图像相对于原始图像的宽度或高度。因此,percentualWidth 为 1 将在水平轴上不进行裁剪,而 percentualWidth 为 0.5 将在水平轴上裁剪一半的图像。
例如,裁剪图像的左上角四分之一(在水平和垂直方向上各裁剪一半)。

let croppedImage = cropper.crop(image: originalImage, anchor: .topLeft, percentualWidth: 0.5, percentualHeight: 0.5)