CropView 0.1.6

CropView 0.1.6

nikitarazumnuy 维护。



CropView 0.1.6

  • nikitarazumnuy

CropView

类似于便签应用的四边形视图和图像裁剪器

示例

Screenshot

用法

初始化

设置初始坐标为点

cropView.configureWithCorners(corners: [CGPoint(x: 120, y: 100),
                                        CGPoint(x: 270, y: 170),
                                        CGPoint(x: 280, y: 450),
                                        CGPoint(x: 120, y: 400)], on: imageView)

自定义

自定义角落/轮廓的颜色和角落大小

// SECornerView.swift
static var cornerSize : CGFloat = 50.0
// SECropView.swift
static var goodAreaColor = #colorLiteral(red: 0.4666666687, green: 0.7647058964, blue: 0.2666666806, alpha: 1)
static var badAreaColor  = #colorLiteral(red: 0.9254902005, green: 0.2352941185, blue: 0.1019607857, alpha: 1)

几何学

// SEQuadrangleHelper.swift

// Crop image by quadrangle points in pixels
static public func cropImage(with image: UIImage, quad: [CGPoint]) throws -> UIImage
// get image frame in UIImageView and convert quadrangle coordinates into image pixels
static public func getCoordinatesOnImageWithoutScale(on imageView: UIImageView, with cropView: SECropView) throws -> Array<CGPoint>
// get quadrangle coordinates, related by UIImageView frame in pixels
static public func getCoordinatesOnImageView(on imageView: UIImageView, with cropView: SECropView) throws -> Array<CGPoint>