美文网首页
图片裁剪

图片裁剪

作者: redye | 来源:发表于2015-11-04 15:21 被阅读123次

    其实我最主要的目的只是需要将图片裁剪成正方形...

    ** AGSimpleImageEditorView **

    你可以从这里下载到它的源码以及使用的官方 Demo。

    我使用到的功能很简单
    - (void)viewDidLoad {
    [super viewDidLoad];

        UIImage *image = [UIImage imageNamed:@"0.jpg"];
        _editView = [[AGSimpleImageEditorView alloc] initWithFrame:CGRectMake(50, 100, 250, 250)];
        _editView.image = image;
        _editView.borderColor = [UIColor greenColor]; //外边框的颜色
        _editView.borderWidth = 5.0f;
        _editView.ratio = 1.0f;
        _editView.ratioViewBorderColor = [UIColor blueColor];
        _editView.ratioViewBorderWidth = 3.0f;
        [_editView imageCenter];  //这个方法是我自己添加的,我本来的效果只是要图片的中间部分
        [self.view addSubview:_editView];
    
        self.imageView.backgroundColor = [UIColor greenColor];
        self.imageView.image = _editView.output;
    
    } 
    
    - (IBAction)applyCropImageClick:(id)sender {
        self.imageView.image = self.editView.output;
    } 
    

    参考请点击这里
    效果

    image.gif

    相关文章

      网友评论

          本文标题:图片裁剪

          本文链接:https://www.haomeiwen.com/subject/xloqhttx.html