Skip to content

jonasbeckers/CropView

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CropView

Quadrangle view and image cropper like a Notes App

Demo

Usage

Initialization

Set initial coordinates in points Also autolayout is supported too, see sample for details

let cropView = SECropView()
cropView.frame = view.frame
cropView.configureWithCorners(corners: [CGPoint(x: 100, y: 120),
CGPoint(x: 270, y: 170),
CGPoint(x: 280, y: 450),
CGPoint(x: 120, y: 400)])
view.addSubview(cropView)

Customisation

Customize color of your corners/contour and corners size

// 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)

Geometry

// 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>

About

Crop rectangle view like in Notes App

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.7%
  • Ruby 3.3%