本文介绍了相机下方有一个黑色的底部空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 UITabBarController 中显示 UIImagePickerController

 让imagePicker = UIImagePickerController()
imagePicker.delegate =自我
imagePicker.sourceType = .Camera
imagePicker.allowsEditing = false
imagePicker.showsCameraControls = false

presentViewController(imagePicker,动画:true,完成:nil)

我已将 showsCameraControls 显式设置为false,以将自定义叠加层视图放置在相机顶部。但是为什么底部有一个黑色空间?有帮助吗? / p>

解决方案

相机纵横比为4:3,您必须应用变换比例才能获得全屏显示



迅速

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

屏幕截图





目标C

  CGSize screenSize = [[UIScreen mainScreen] bounds] .size; 
的float AspectRatio = 4.0 / 3.0;
浮动比例= screenSize.height / screenSize.width * AspectRatio;
self.imagePikerViewController.cameraViewTransform = CGAffineTransformMakeScale(scale,scale);


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?

解决方案

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

这篇关于相机下方有一个黑色的底部空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 01:54