我从UIImagePickerController
提出UITabBarController
。
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
imagePicker.allowsEditing = false
imagePicker.showsCameraControls = false
presentViewController(imagePicker, animated: true, completion: nil)
我已将showsCameraControls
明确设置为false,以将我的自定义叠加视图放在相机顶部。但为什么底部有黑色空间?有什么帮助?
答案 0 :(得分:10)
相机宽高比为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;
float scale = screenSize.height/screenSize.width * aspectRatio;
self.imagePikerViewController.cameraViewTransform = CGAffineTransformMakeScale(scale, scale);