【问题标题】:cameraOverlayView to crop the result in UIImagePickerControllercameraOverlayView 在 UIImagePickerController 中裁剪结果
【发布时间】:2010-08-23 07:06:01
【问题描述】:
【问题讨论】:
标签:
iphone
uiimagepickercontroller
ios
【解决方案1】:
- 将 UIImageView 作为子项添加到您的 cameraOverlayView。
- 创建大小为 320x480 的黑色 PNG 图像。在中间切一个矩形以产生一个孔(透明像素)。
- 将 PNG 图像分配给 UIImageView。
或者,您可以像这样覆盖您的 cameraOverlayView 的 - (void)drawRect:(CGRect)rect(未经测试):
// Request draw context
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw background
CGContextSetRGBFillColor(context, 0.0f, 0.0f, 0.0f, 1.0f);
CGContextFillRect(context, rect);
// Cut hole
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextFillRect(context, CGRectMake(40, 40, 100, 100);
我在我的 Faces 应用 (http://faces.pixelshed.net/) 中做了类似的事情。如果其中一个步骤不清楚,请随时发表评论。