当我将 UIImagePickerController
与 cameraOverlayView
一起使用时,我能否从叠加 View 中获取唯一的选择区域?
最佳答案
- 将 UIImageView 作为 subview 添加到您的 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/) 中做了类似的事情。如果其中一个步骤不清楚,请随时发表评论。
关于iphone - cameraOverlayView 在 UIImagePickerController 中裁剪结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3545362/