Camera with Custom View Camera with Custom View ios ios

Camera with Custom View


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.

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.


Create a UIImagePickerController from code, adjust its properties, add an overlay onto it, and with you controller, control whatever you want on that overlay : custom controls, overlaying images, etc...

That gives something like this :

self.picker = [[UIImagePickerController alloc] init];self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;self.picker.showsCameraControls = NO;self.picker.navigationBarHidden = YES;self.picker.toolbarHidden = YES;self.picker.wantsFullScreenLayout = YES;// Insert the overlayself.overlay = [[OverlayViewController alloc] initWithNibName:@"Overlay" bundle:nil];self.overlay.pickerReference = self.picker;self.picker.cameraOverlayView = self.overlay.view;self.picker.delegate = self.overlay;[self presentModalViewController:self.picker animated:NO];

OverlayViewController is the controller that you must write to control everything you add onto the overlay.

pickerReference is a property you can keep to send orders to the camera. For example, you could call the following from an IBAction coming from a UIButton placed onto the overlay :

[self.pickerReference takePicture];


Read the UIImagePickerController Class Reference, that's right in the documentation…

There are properties for this, especially the cameraOverlayView and showsCameraControls properties.

So you can hide the controls, provide a custom overlay view, and add subviews to this custom view to add custom buttons, frames, etc.