具有自定义视图的相机 [英] Camera with Custom View

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

问题描述

我的应用程序使用相机,我想在相机预览上添加叠加层.比如我想在使用Camera的时候使用一个相框,也想为相机操作添加一个自定义栏.请帮助我做同样的事情.

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 对象.此视图负责显示相机的提要.您可以根据需要调整该视图的大小,并且相机的输入将显示在该区域中.您还可以根据自己的选择将框架图像放在它周围.

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.

当我想调整相机输入源的大小并拍摄照片时,它对我有用.我希望它也对你有用.

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天全站免登陆