There is a black bottom space below the camera

為{幸葍}努か 提交于 2019-12-21 17:22:49

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/31152040/there-is-a-black-bottom-space-below-the-camera

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!