【问题标题】:cameraOverlayView to crop the result in UIImagePickerControllercameraOverlayView 在 UIImagePickerController 中裁剪结果
【发布时间】:2010-08-23 07:06:01
【问题描述】:

当我将UIImagePickerControllercameraOverlayView 一起使用时,我能否从叠加视图中获得唯一的选择性区域?

http://tinyurl.com/2fqy9nq

【问题讨论】:

标签: iphone uiimagepickercontroller ios


【解决方案1】:
  1. 将 UIImageView 作为子项添加到您的 cameraOverlayView。
  2. 创建大小为 320x480 的黑色 PNG 图像。在中间切一个矩形以产生一个孔(透明像素)。
  3. 将 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/) 中做了类似的事情。如果其中一个步骤不清楚,请随时发表评论。

【讨论】:

    猜你喜欢
    • 2013-08-19
    • 1970-01-01
    • 2014-10-12
    • 1970-01-01
    • 2010-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多