要运行示例项目,请克隆存储库,首先从示例目录运行pod install
此类支持在scrollView中以裁剪选项显示图像。用户可以将图像移动到所需的裁剪位置并旋转。对于旋转,我们使用UIImage+Scale与fixOrientation(相机中的照片)。
您可以在任何视图中使用它,只需设置正确的frame(在所需的长宽比中)并在调用croppedImage之后,您将获得所需的图像。
[[self scrollView] croppedImageWithBlock:^(UIImage *image) {
[self.preview setImage:image];
}];
您还可以在scrollView上绘制覆盖层并在滑动视图的边界外绘制图像
[self.scrollView setClipsToBounds:NO];
[[self cropOverlay] setCropScrollView:[self scrollView]];
[[self cropOverlay] setNeedsDisplay];
根据需要,可以从nib或代码中创建scrollView和覆盖层。自动大小掩码工作不正确(未来的更新)?
如果您不想使用当前的scrollView,您只能使用裁剪选项
+ (UIImage*)cropImage:(UIImage*)image forScrollViewFrame:(CGRect)frame andZoomScale:(float)zoomScale andContentOffset:(CGPoint)contentOffset andBarColor:(UIColor*)color
iOS5+
IMCropScrollView通过CocoaPods提供。要安装它,只需将以下行添加到您的Podfile中
pod 'IMCropScrollView', '~> 1.1.1'
Martin Kluska, [email protected]
IMCropScrollView在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。