cameraOverlayView在UIImagePickerController中裁剪结果

Dot*_*Dot 3 iphone uiimagepickercontroller ios

当我使用UIImagePickerControllercameraOverlayView,我可以从叠加视图中获得唯一的选区吗?

http://tinyurl.com/2fqy9nq

Lar*_*der 7

  1. 将UIImageView作为子项添加到cameraOverlayView.
  2. 创建黑色PNG图像大小320x480.在中间切一个矩形以产生一个洞(透明像素).
  3. 将PNG图像分配给UIImageView.

或者你可以- (void)drawRect:(CGRect)rect像这样覆盖你的cameraOverlayView (未经测试):

// 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);
Run Code Online (Sandbox Code Playgroud)

我在Faces应用程序(http://faces.pixelshed.net/)中做了类似的事情.如果其中一个步骤似乎不清楚,请随意写评论.