我从 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 放在相机顶部。但是为什么底部有一个黑色区域?有什么帮助吗?
最佳答案
相机宽高比是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/