【发布时间】:2017-01-04 01:52:08
【问题描述】:
我的目标 c 应用程序中有一个 UIImageView。在这个UIImageView 上,我加载了一张照片,然后从相机中拍摄。我应用一个区域来裁剪UIImage。该区域是CAShapeLayer 的矩形。但我的问题是,当我将框架包含在矩形中时,这与我的矩形所在的位置不同......我得到一个错误的区域然后裁剪。
我使用这个代码:
CAShapeLayer *_outline = [CAShapeLayer new];
UIImageView *vistaImagen;
...
UIGraphicsBeginImageContextWithOptions(_vistaImagen.frame.size, NO, 0.0);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextAddPath(context, _boundingBox.accessibilityPath.CGPath);
CGContextClip(context);
[_vistaImagen.layer renderInContext:context];
UIImage *iii = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
如果我添加了要裁剪的图层框架,可能会出现什么问题:_boundingBox.accessibilityPath.CGPath ??
谢谢!!
【问题讨论】:
标签: ios objective-c uiimageview uiimage cgpath