When you implement a cameraOverlayView
for a UIImagePickerController
, this view appears while you're taking the photo and after the photo has been taken, providing you with an opportunity to cancel or retake the photo. The problem I'm seeing is if your cameraOverlayView
is on top of the photo preview area, when you take the photo and it shows you the preview, the photo you took doesn't align with the cameraOverlayView
anymore. The entire photo preview pane has been moved down ~50 points while the cameraOverlayView
has stayed in place. This is a problem when you need the photo to be aligned perfectly with the view.
How can this be adjusted so the two are perfectly aligned - while taking the photo and after it has been taken?
Notice how the whole preview area is pushed down after taking the photo.
I had a similar problem and came up with the following workaround:
if (IPhone5 || IPhone5c || IPhone5s)
{
imagePicker.cameraViewTransform = CGAffineTransformTranslate(imagePicker.cameraViewTransform, 0, 30);
}
else if (IPhone6 || IPhone6Plus)
{
imagePicker.cameraViewTransform = CGAffineTransformTranslate(imagePicker.cameraViewTransform, 0, 44);
}
This ensures that the picture that was taken will have approximately the same center as the camera preview layer (in portrait orientation).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With