2015-10-27 61 views
1

我隐藏了我的相机控件,但是留下了一个很大的黑色空间。为了解决这个问题,我正在寻找缩放我的相机,使其充满整个屏幕。我不知道为什么我无法做到这一点。这是我的代码。干杯!如何缩放我的imagePickerController相机以填充整个屏幕?

imagePicker.sourceType = UIImagePickerControllerSourceType.Camera 
imagePicker.delegate = self 
imagePicker.allowsEditing = false 
imagePicker.showsCameraControls = false 
imagePicker.cameraOverlayView = overlayView 
self.presentViewController(imagePicker, animated: false, completion: nil) 

回答

0

我相信相机的纵横比为4/3,所以你必须为了使相机全屏幕应用转换的规模。

let screenSize = UIScreen.mainScreen().bounds.size 
let aspectRatio:CGFloat = 4/3 
let scale = screenSize.height/screenSize.width * aspectRatio 
self.imagePikerViewController.cameraViewTransform = CGAffineTransformMakeScale(scale, scale); 
0

由于相机长宽比为4:3,因此无法使用全屏相机。

但是,您可以拉伸图像以填充屏幕。但个人我不会推荐,因为图像可能看起来不正确。 尽管您可以使用AV Foundation,但AVCaptureVideoPreviewLayer尤其可以实现相同效果。你可以参考这些链接 1. https://developer.apple.com/library/prerelease/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/00_Introduction.html 2. https://developer.apple.com/av-foundation/ 欲了解更多信息。 希望它有帮助... Happy Coding .. :)