为 iOS 提供了另一个用于裁剪图像的 UI。与内置照片应用中的裁剪 UI 类似,但没有自动缩放的行为。
MIT 许可协议。
ASMCropImageViewController* controller = [[ASMCropImageViewController alloc] init];
controller.image = [UIImage imageNamed:@"IMG_7999.jpg"];
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navController animated:YES completion:NULL];
默认情况下,裁剪框不受任何宽高比限制。您可以不通过任何方式更改这一点。
controller.aspectRatio = CGSizeMake(9, 16);
要回到不受限制的模式,只需将 aspectRatio 设置为零尺寸。
UIImage* croppedImage = [controller croppedImage];
可以在视图呈现后随时调用此方法,并且可以频繁调用。
此功能目前基本未经测试,并且尚未用于任何生产代码。请小心操作!