登录 立即注册
金钱:

Code4App-iOS开发-iOS 开源代码库-iOS代码实例搜索-iOS特效示例-iOS代码例子下载-Code4App.com

LECropPictureViewController

[复制链接]
来自: 李世铿 分类: iOS精品源码 上传时间: 2016-6-16 11:46:32
Tag:crop 裁剪 圆形 图片 image image

项目介绍:

一个漂亮的图形裁剪编辑器组件。支持缩放,手势操作,可以将一张大图裁剪至指定的大小。
Install
安装方法
Manually
Drag and copy all files in the LECropPictureViewController folder into your project, or add it as a git submodule.
LECropPictureViewController文件拖拽进入项目中。

CocoaPods 支持
cocoapods
LECropPictureViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "LECropPictureViewController", "~> 0.1"

How to use 使用方法
[Objective-C] 查看源文件 复制代码
LECropPictureViewController works with any image. You just have to provide the image and a cropType when creating a new instance, and then present the view controller. The possible cropTypes are:

LECropPictureTypeRounded
LECropPictureTypeRect
#import "LECropPictureViewController.h"

LECropPictureViewController *cropPictureController = [[LECropPictureViewController alloc] initWithImage:image andCropPictureType:LECropPictureTypeRounded];
[self presentViewController:cropPictureController animated:YES completion:nil];



The callback for the cropped picture is given through a block.
通过block来回传裁剪过的图片
[Objective-C] 查看源文件 复制代码
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
    UIImage *image = info[UIImagePickerControllerOriginalImage];

    [self dismissViewControllerAnimated:NO completion:nil];

    LECropPictureViewController *cropPictureController = [[LECropPictureViewController alloc] initWithImage:image andCropPictureType:LECropPictureTypeRounded];
    cropPictureController.imageView.contentMode = UIViewContentModeScaleAspectFit;

    cropPictureController.photoAcceptedBlock = ^(UIImage *croppedPicture){
        self.imageView.image = croppedPicture;
    };

    [self presentViewController:cropPictureController animated:NO completion:nil];
}






Customizing 自定义属性

[Objective-C] 查看源文件 复制代码
The LECropPictureViewController has public properties for it's components. With this, you can do things like changing the contentMode of the imageView, changing the text of the barButtonItems, etc.

@property (weak, nonatomic) UIBarButtonItem *cancelButtonItem;
@property (weak, nonatomic) UIBarButtonItem *acceptButtonItem;
@property (weak, nonatomic) UIImageView *imageView;
Besides the subviews, you can customize other things like the initial frame of the crop area, borderColor and borderWidth, like below:

(...)
LECropPictureViewController *cropPictureController = [[LECropPictureViewController alloc] initWithImage:image andCropPictureType:LECropPictureTypeRounded];
cropPictureController.cropFrame = CGRectMake(50, 50, 250, 250);
cropPictureController.borderColor = [UIColor grayColor];
cropPictureController.borderWidth = 1.0;
(...)
You can even implement the @property(copy) void(^photoRejectedBlock)();, if you want to override the default behaviour of the cancel button (which only dismiss the controller). Be aware that, if you do this, you will be responsible to dismiss the controller yourself.

cropPictureController.photoRejectedBlock = ^{
    NSLog(@"Doing something here!");
    [self dismissViewControllerAnimated:YES completion:nil];
};



代码下载:





相关源码推荐:

我来说两句
*滑动验证:
所有评论(205)
初冬 2016-6-16 13:38:47
我只是路过打酱油的。
回复
Super_Yuan 2016-6-16 13:40:07
虽不明,但觉厉!
回复
Super_Yuan 2016-6-16 13:42:08
感谢分享,Code4App有你更精彩:)
回复
ogqs0493 2016-6-16 13:49:35
我只是路过打酱油的。
回复
0123456789ooooo 2016-6-16 14:08:46
正需要啊,感谢楼主无私分享!
回复
石强 2016-6-16 15:36:56
楼主用心了,内容非常精彩。
回复
李伟鹏 2016-6-16 15:43:13
淡定,淡定,淡定……
回复
tkvc0177 2016-6-16 16:39:07
感谢分享,Code4App有你更精彩:)
回复
王颖博 2016-6-16 16:49:14
正需要啊,感谢楼主无私分享!
回复
提取码:  下载次数:150 状态:已购或VIP 售价:0(原价:10)金钱 下载权限:初级码农 
3906 1 150
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542

如何获得代码达人称号?

代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表