测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
Released最新发布 | 2014 年 12 月 |
由 kishikawa katsumi 维护。
PEPhotoCropEditor 是 iOS 的图像裁剪库,类似于 Photos.app 的用户界面。
使用视图控制器组件
PECropViewController *controller = [[PECropViewController alloc] init];
controller.delegate = self;
controller.image = self.imageView.image;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navigationController animated:YES completion:NULL];
直接使用裁剪视图
self.cropView = [[PECropView alloc] initWithFrame:contentView.bounds];
[self.view addSubview:self.cropView];
代理方法
- (void)cropViewController:(PECropViewController *)controller didFinishCroppingImage:(UIImage *)croppedImage
{
[controller dismissViewControllerAnimated:YES completion:NULL];
self.imageView.image = croppedImage;
}
直接从视图获取
UIImage *croppedImage = self.cropView.croppedImage;
controller.keepingCropAspectRatio = YES;
self.cropView.keepingCropAspectRatio = YES;
// e.g.) Cropping center square
CGFloat width = image.size.width;
CGFloat height = image.size.height;
CGFloat length = MIN(width, height);
controller.imageCropRect = CGRectMake((width - length) / 2,
(height - length) / 2,
length,
length);
// e.g.) Cropping center square
CGFloat width = image.size.width;
CGFloat height = image.size.height;
CGFloat length = MIN(width, height);
self.cropView.imageCropRect = CGRectMake((width - length) / 2,
(height - length) / 2,
length,
length);
[controller resetCropRect];
[self.cropView resetCropRect];
PEPhotoCropEditor 提供 MIT 许可证。请参阅 LICENSE 文件以获取更多信息。