相机与自定义视图 [英] Camera with Custom View

查看:181
本文介绍了相机与自定义视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式使用相机,我想在相机预览中加入重叠。例如,我想在使用相机时使用相框,我也想为相机操作添加自定义栏。请帮我做同样的事。

My Application uses camera, I would like to add overlay over the camera preview. For example, I want to use a picture frame when I use Camera, also I would like to add a custom bar for camera operations. Kindly help me to do the same.

推荐答案

您可能正在尝试使用UIImagePickerController。但我知道这一个解决你的问题。你可以很容易地使用AVCamCaptureManager和AVCamRecorder类。 Apple在其开发者网站上创建了一个演示程序这里。它被命名为AVCam。简单来说,它是做什么的是当你点击打开相机,它调用类和方法,负责打开iPhone的相机和录制视频或捕获音频。它调用由UIImagePickerController调用的相同的类。因此,您的相机将打开并开始接受输入。

You might be trying using UIImagePickerController. But I know this one solution to your problem. You can do it easily using AVCamCaptureManager and AVCamRecorder classes. Apple has a demo program build on its developer site here. It is named AVCam. In simple words what it does is when you click to open the camera, it calls the classes and methods which are responsible for opening the iPhone's camera and record video or capture audio. It calls the same classes which are called by UIImagePickerController. So your camera will open and start taking input.

现在,如果打开AVCam项目的xib文件,您会发现一个小的UIView对象。此视图负责显示相机的Feed。您可以根据所需的大小调整该视图的大小,相机的输入将显示在该区域。你也可以根据你的选择放置框架图像。

Now, if you open the xib file of that AVCam project, you'll find a small UIView object. This view is responsible for displaying the camera's feed. You can resize that view as per the size you want and the camera's input will be displayed in that much area. You can also put the frame image around it as per your choice.

当我想调整相机的输入Feed和捕获照片时,它适用于我。我希望它也适合你。

It worked for me when I wanted to resize the camera's input feed and capture photos. I hope it works for you as well.

这篇关于相机与自定义视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆