3 Star 1 Fork 0

Gitee 极速下载 / JPCrop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/Rogue24/JPCrop
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

JPCrop

Language

effect

Example

Tool class with high imitation of cutting function of little red book app. Juejin Blog

example

高仿小红书App裁剪功能的工具:
    1.集成类似小红书基本的裁剪功能(自定义裁剪比例 + 360°任意旋转);
    2.API简单易用;
    3.切换裁剪比例带有动画过渡,不会那么生硬;
    4.可异步可同步裁剪,并且可压缩。

How to use

Is so easy:

Initialization

// 1.Import
import JPCrop

// 2.Initialize
let frame = CGRect(...
let configure = Croper.Configure(image)
let croper = Croper(frame: frame, configure)

// 3.Add to superview, done!
view.insertSubview(croper, at: 0)

Rotate

/**
 * originAngle: Rotation origin angle.
 * There are four origins: 0°/360°, 90°, 180°, 270°
 * The rotatable angle range of each origin angle is: -45° ~ 45°
 */
 
// Rotate (Rotatable angle range: Based on the current origin angle -45° ~ 45°)
croper.rotate(angle)

// Rotate left (originAngle - 90°)
// animated: with animation or not
croper.rotateLeft(animated: true)
        
// Rotate right (originAngle + 90°)
// animated: with animation or not
croper.rotateRight(animated: true)

// Show grid before rotating
// animated: with animation or not
croper.showRotateGrid(animated: true)

// Hide grid after rotating
// animated: with animation or not
croper.hideRotateGrid(animated: true)

Switch the crop width to height ratio

// rotateGridCount: Number of grid in rotation. (ver, hor)
// animated: with animation or not
croper.updateCropWHRatio(3.0 / 4.0, rotateGridCount: (6, 5), animated: true)

Reset

// animated: with animation or not
croper.recover(animated: true)

Crop

let configure = croper.syncConfigure()

// 1.Sync crop
let image = croper.crop() 
cropDone(image, configure)

// 2.Async crop: crop in DispatchQueue.global, result back to DispatchQueue.main 
croper.asyncCrop {
    guard let image = $0 else { return }
    cropDone(image, configure)
}

// PS: You can set the compressionScale to compress the image

More features will be added in the future...

Installation

JPCrop is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'JPCrop'

Author

Rogue24, zhoujianping24@hotmail.com

License

JPCrop is available under the MIT license. See the LICENSE file for more info.

Copyright (c) 2020 Rogue24 <zhoujianping24@hotmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

JPCrop 是一个高仿小红书 App 裁剪功能的轻量级工具,使用 Swift 语言开发,适用于 iOS 系统 展开 收起
Swift
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Swift
1
https://gitee.com/mirrors/JPCrop.git
git@gitee.com:mirrors/JPCrop.git
mirrors
JPCrop
JPCrop
master

搜索帮助