cameraOverlayView裁剪UIImagePickerController中的结果

当我使用cameraOverlayView使用UIImagePickerController时,是否可以从覆盖视图中获得唯一的区域?

http://tinyurl.com/2fqy9nq

  1. 添加一个UIImageView作为孩子到您的cameraOverlayView。
  2. 创build一个黑色的PNG图像尺寸320×480。 在中间切一个矩形产生一个洞(透明像素)。
  3. 将PNG图像分配给UIImageView。

或者,你可以覆盖你的cameraOverlayView的- (void)drawRect:(CGRect)rect像这样(未经testing我的头):

 // 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/ )中做了类似的事情。 如果其中一个步骤似乎不清楚,请随时发表评论。