There is a black bottom space under the camera
I represent UIImagePickerController
from UITabBarController
.
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
imagePicker.allowsEditing = false
imagePicker.showsCameraControls = false
presentViewController(imagePicker, animated: true, completion: nil)
I explicitly set it showsCameraControls
to false to put my custom top view on top of the camera. But why is there black space at the bottom? Any help?
+3
source to share
1 answer
The aspect ratio of the camera is 4: 3, you need to apply the transformation scale so that you can get the full screen
Swift
let screenSize = UIScreen.mainScreen().bounds.size
let aspectRatio:CGFloat = 4.0/3.0
let scale = screenSize.height/screenSize.width * aspectRatio
self.imagePikerViewController.cameraViewTransform = CGAffineTransformMakeScale(scale, scale);
Screenshot
Objective C
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
float aspectRatio = 4.0/3.0;
float scale = screenSize.height/screenSize.width * aspectRatio;
self.imagePikerViewController.cameraViewTransform = CGAffineTransformMakeScale(scale, scale);
+8
source to share