Coder Social home page Coder Social logo

beecustomphoto's Introduction

###单选 (选择图片-图片编辑-图片裁剪)
首先导入BeeDIYPhoto.h ,继承<UIBeeDIYPhototDelegate>
直接初始化后传入一个裁剪的比例,然后就可以在代理方法拿到返回的图片

- (void)beePhoto
{
    [BeeDIYPhotoImage showActionSheetInFatherViewController:self andScale:scare_1_1 delegate:self];
}

- (void)beeDiyTheImage:(UIImage *)image
{
    [self.img setImage:image];
}

这里的比例是由一个枚举决定的,大家如果有想自己定义的可以自行添加上去

typedef NS_ENUM(NSInteger, CYCropScaleType) {
    CYCropScaleTypeCustom,
    CYCropScaleTypeOriginal,
    CYCropScaleType1To1,
    CYCropScaleType3To2,
    CYCropScaleType2To3,
    CYCropScaleType4To3,
    CYCropScaleType3To4,
    CYCropScaleType16To9,
    CYCropScaleType9To16,
    CYCropScaleType46To35,
};

我在调用方法的类里定义了宏

#define scare_1_1   @"2" // 根据上枚举第几个。。。可以自己前往定义CYCropView增加自定义比例

###多选 (选择图片-返回图片数组)
这里我们直接导入BeePhotoGropViewController,初始化把selectmore设置为yes,maxcount为你选择图片的最大数量,之后再getimageblock回调里可以得到返回的图片数组,注意这里返回的是data
这里的相册也做了一点小优化,进入后会直接刷新到底部。图片700多张的时候可能会加载几秒,可以考虑加上风火轮优化效果

- (void)moreAction
{
    BeePhotoGropViewController *vc = [[BeePhotoGropViewController alloc]init];
    vc.selectMore = YES;
    vc.maxcount = 2;  // 最多两张图片
    WS(weakSelf);
    vc.getImgArrBlock = ^(NSArray *arr){
//        NSLog(@"多选的图片data数组:imgdata = %@",arr);
        if (arr.count > 0) {
            if (arr[0]) {
                [weakSelf.img1 setImage:[UIImage imageWithData:arr[0]]];
            }
        }
        if (arr.count == 2) {
            if (arr[1]) {
                [weakSelf.img2 setImage:[UIImage imageWithData:arr[1]]];
            }
        }
    };
    UINavigationController *nvc =  [[UINavigationController alloc]initWithRootViewController:vc];
    [self presentViewController:nvc animated:YES completion:nil];
}

效果演示如下:
![gif](https://github.com/iOSJYF/beeCustomPhoto/raw/master/beeCustomPhoto.gif)

beecustomphoto's People

Contributors

iosjyf avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.