PhotoTweaks 是一个照片裁剪接口。它可以允许用户拖动、旋转、缩放图像并进行裁剪。您会发现它与 iOS 8 上 Photos.app 的交互非常相似 :]
PhotoTweaksViewController 提供了所有的照片裁剪操作,包括平移、旋转和缩放等。
要使用它,
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
PhotoTweaksViewController *photoTweaksViewController = [[PhotoTweaksViewController alloc] initWithImage:image];
photoTweaksViewController.delegate = self;
[picker pushViewController:photoTweaksViewController animated:YES];
获取裁剪图像
- (void)photoTweaksController:(PhotoTweaksViewController *)controller didFinishWithCroppedImage:(UIImage *)croppedImage
{
[controller.navigationController dismissViewControllerAnimated:YES completion:nil];
// cropped image
}
PhotoTweaks 可在 CocoaPods 上使用。将以下内容添加到您的 Podfile 中:
pod 'PhotoTweaks', '~> 1.0.1'
或者,您可以手动将 PhotoTweaks
文件夹拖入您的 Xcode 项目中。
如果您与现有的 UIImagePickerController 一起使用,请确保设置 allowsEditing = NO
,否则您可能需要在显示 PhotoTweaksViewController 之前强制用户使用原生编辑工具进行裁剪。