Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

There is a black bottom space below the camera

I am presenting an UIImagePickerController from a UITabBarController.

        let imagePicker = UIImagePickerController()
        imagePicker.delegate = self
        imagePicker.sourceType = .Camera
        imagePicker.allowsEditing = false
        imagePicker.showsCameraControls = false

        presentViewController(imagePicker, animated: true, completion: nil)

I have explicitly set showsCameraControls to false to put my custom overlay view on top of camera.But why there is a black space on the bottom?any helps?

enter image description here

like image 982
tounaobun Avatar asked Jul 01 '15 03:07

tounaobun


1 Answers

The camera aspect ratio is 4:3,you have to apply a transform scale so that you can get 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);

Screen shot

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);
like image 120
Leo Avatar answered Sep 17 '22 23:09

Leo