ios - 摄像头下方有一个黑色的底部空间

标签 ios swift camera uitabbarcontroller uiimagepickercontroller

我从 UITabBarController 呈现一个 UIImagePickerController

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

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

我已明确将 showsCameraControls 设置为 false 以将我的自定义叠加 View 放在相机顶部。但是为什么底部有一个黑色区域?有什么帮助吗?

enter image description here

最佳答案

相机宽高比是4:3,你必须应用变换比例才能全屏

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

屏幕截图

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

关于ios - 摄像头下方有一个黑色的底部空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31152040/

相关文章:

ios - 在没有应用程序崩溃的情况下向 Crashlytics 发送日志

iphone - 密码强度库 - Objective C

ios - 如何访问 UICollectionViewController header 中的 UISegmentedControl?

android - 制作位图时内存不足错误

javascript - 通过渐进式网络应用在移动设备上打开相机

iPhone 相机可以快速拍摄照片,但保存照片时遇到问题

ios - 如何在 NSAttributedString 中创建可点击链接?

iphone - UIScrollView动态调整UILabel的大小

ios - 如何在按下按钮时转到 tableView 的顶部

ios - 搜索后访问索引路径行