DLImageCroper provides a simple solution for capturing current images, with five built-in width to height ratios by default
@”1:1″,@”3:4″,@” original ratio “,@”3:2″,@”16:9”
DLCropImageView is provided by default for display, just need the following code, if you do not need the built-in DLCropImageView, you can also use DLCropImageView to implement their own methods.
usage
self.cropView = [[DLCropImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)]; self.cropView.layer.cornerRadius = 5; self.cropView.layer.masksToBounds = YES; self.cropView.backgroundColor = [UIColor redColor]; __weak typeof(self)weakSelf = self; self.cropView.shouldChoseImageBlock = ^{ [weakSelf choseImage]; }; / / optional whether to show the self. The delete button cropView. ShouldShowDelBtn = YES; [self.view addSubview:self.cropView];Copy the code
Custom aspect ratios are also supported, for example
NSMutableArray * arr = [NSMutableArray new]; NSArray * nameArr = @[@"1:1",@"3:1",@"1:3"]; NSArray * valArr = @[@1, @3, @0.333]; for (int i = 0; i< 3; i++) { DLImageItemRatioModel * mo = [[DLImageItemRatioModel alloc]init]; mo.name = nameArr[i]; mo.ratio = [valArr[i] doubleValue]; [arr addObject:mo]; } self.cropView = [[DLCropImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)]; self.cropView.layer.cornerRadius = 5; self.cropView.layer.masksToBounds = YES; self.cropView.ratioArr = arr.copy; / / custom capture ratio self. CropView. BackgroundColor = [UIColor redColor]; __weak typeof(self)weakSelf = self; self.cropView.shouldChoseImageBlock = ^{ [weakSelf choseImage]; }; / / optional whether to show the self. The delete button cropView. ShouldShowDelBtn = YES; [self.view addSubview:self.cropView];Copy the code
Circular clipping is supported with a single line of code
self.cropView.isRound = YES;
Copy the code
Making the address