相机下方有一个黑色底部空间

时间:2015-07-01 03:25:30

标签: ios swift camera uitabbarcontroller uiimagepickercontroller

我从UIImagePickerController提出UITabBarController

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

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

我已将showsCameraControls明确设置为false,以将我的自定义叠加视图放在相机顶部。但为什么底部有黑色空间?有什么帮助?

enter image description here

1 个答案:

答案 0 :(得分:10)

相机宽高比为4:3,您必须应用变换比例才能全屏显示

夫特

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);

屏幕截图

目标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);