gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 22:30:02 25 4
gpt4 key购买 nike

我从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com