iphone - cameraOverlayView 在 UIImagePickerController 中裁剪结果

标签 iphone uiimagepickercontroller ios

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

http://tinyurl.com/2fqy9nq

最佳答案

  1. 将 UIImageView 作为 subview 添加到您的 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/) 中做了类似的事情。如果其中一个步骤不清楚,请随时发表评论。

关于iphone - cameraOverlayView 在 UIImagePickerController 中裁剪结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3545362/

相关文章:

iphone - 设备方向更改后窗口 subview 不旋转

iphone - UIWebView 方法 loadHTMLString : and loadRequest 之间的区别

ios - Swift 如何获得 UIScrollView 动态高度

iphone - ios中XMPPFramework的TURNSocket连接成功后如何接收文件?

ios - 保存视频到图库,获取视频存放到图库的路径

ios - AFNetworking + Google Places API Web服务+具有多个baseURL的Parse SDK

ios - 使用 Xcode 6 绕过代码签名

iphone - 单击 alertView 的按钮后,不会调用 alertView didDismissWithButtomIndex

ios - 为 UIImagePicker 添加圆形裁剪组件?

ios - UIImagePickerController 允许我拍摄照片和视频,但不允许我保存它们或 "use"它们