As the title says, I need to create a very simple camera overlay while taking photos with UIImagePickerController
. I want to add very simple .png
f
There is a property of UIImagePickerController
called cameraOverlayView
. It's an UIView*
, so you need to create one and put your PNG to the background of it, then assign it to this property of your picker
.
Ok, here's the code (i didnt test it so)
(IBAction) getPhoto:(id) sender
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
// creating overlayView
UIView* overlayView = [[UIView alloc] initWithFrame:picker.view.frame];
// letting png transparency be
overlayView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"yourimagename.png"]];
[overlayView.layer setOpaque:NO];
overlayView.opaque = NO;
picker.showsCameraControls = NO;
picker.cameraOverlayView = overlayView;
if((UIButton *) sender == choosePhotoBtn)
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
} else {
//do something if the device has no camera or if the camera is disabled in settings (it cannot be assumed that the camera is available/not broken)
}
} else {
}
label1.text =@"PHOTO ACTION";
[self presentModalViewController:picker animated:YES];
}
Of course, you can use some custom UIView*
subclass instead of creating standard UIView* overlayView
, but everything else will remain the same.