- Making portal
- The OC version specializes in cropping the wheels of pictures, GIFs and videos
Introduction to the
1. Integrate basic clipping functions similar to Xiaohongshu; 2.API is simple and easy to use; 3. Animation transition can be set when switching the cutting ratio, which is not so stiff; 4. Asynchronous and synchronous cutting, and compressible.Copy the code
How to use
Is simple:
Initialize the
// 1.Import
import JPCrop
// 2.Initialize
let croper = Croper(frame: croperFrame, configure)
// 3.Add to superview, done!
view.insertSubview(croper, at: 0)
Copy the code
rotating
// The default range is -45° to 45°
croper.updateRadian(radian)
// Show more meshes when rotating
// animated: with animation or not
croper.showRotateGrid(animated: true)
// Hide more meshes after rotation
// animated: with animation or not
croper.hideRotateGrid(animated: true)
Copy the code
Toggle cutting aspect ratio
// Number of grid in rotation can be updated
// Animated: Whether animated or animated
croper.updateCropWHRatio(3.0 / 4.0, rotateGridCount: (6.5), animated: true)
Copy the code
restore
// Return to 0°, scale 1, center position
// Animated: Whether animated or animated
croper.recover(animated: true)
Copy the code
tailoring
let configure = croper.syncConfigure()
// 1
let image = croper.crop()
cropDone?(image, configure)
Dispatchqueue. global dispatchqueue. main dispatchqueue. main dispatchqueue. main dispatchqueue. main dispatchqueue. main
croper.asyncCrop {
guard let image = $0 else { return }
cropDone(image, configure)
}
// PS: You can set the compressionScale property to compress images proportionally.
Copy the code
More features to come…
The installation
JPCrop is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'JPCrop'
Copy the code
If there is a Bug please contact me, thanks ~
Rogue24, [email protected]