If you want to display the overlay on top of the UIImagePickerController, for example, in my case, and at the same time adjust the "live camera" controller (view) between some components of the user interface on your overlay (for example, the top panel and the bottom panel), use the following code. This is based on SomaMan's answer above (THANKS), with the main difference being displaying the UIImagePickerController as a sub-view of the current controller, and not as a subspecies of the main application window. Put this code in viewDidLoad ():
// Overlay view with custom camera controls and a top bar and a bottom bar self.overlay = [[CameraOverlayView alloc] initWithFrame:self.view.bounds]; [self setOverlayViewModel]; self.imagePicker = [[UIImagePickerController alloc] init]; self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; self.imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto; self.imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOff; self.imagePicker.showsCameraControls = NO; self.imagePicker.navigationBarHidden = YES; self.imagePicker.toolbarHidden = YES; self.imagePicker.delegate = self; UIView *imagePickerView = self.imagePicker.view; if ([[UIScreen mainScreen] bounds].size.height == 568.0f) { // iPhone 5, 16:9 ratio, need to "zoom in" in order to fill the screen since there is extra space between top and bottom bars on a taller screen self.imagePicker.cameraViewTransform = CGAffineTransformScale(self.imagePicker.cameraViewTransform, 1.5, 1.5); // change 1.5 to suit your needs } CGRect cameraViewFrame = CGRectMake(0, self.overlay.topBarHeight, self.view.bounds.size.width, self.view.bounds.size.height - self.overlay.topBarHeight - self.overlay.bottomBarHeight); imagePickerView.frame = cameraViewFrame; // keep this order so that the overlay view is on top of the "live camera feed" view [self.view addSubview:imagePickerView]; [self.view addSubview:self.overlay];
TIP. When executing CameraViewTransform, do not forget to apply the same transformation on the resulting photo that the collector will capture for you if you want the user to be in the same image that they see in your converted form: P
source share