我已经在我的应用程序中实现了相机覆盖视图。相机覆盖视图在 iOS 9 中工作良好。但 iOS 10cameraViewTransform 无法工作如何解决此问题。请指导我。谢谢
我的工作代码
CGSize screenBounds = [UIScreen mainScreen].bounds.size;
CGFloat cameraAspectRatio = 4.0f/3.0f;
CGFloat camViewHeight = screenBounds.width * cameraAspectRatio;
CGFloat scale = screenBounds.height / camViewHeight;
picker.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight) / 2.0);
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, scale, scale);
update
OverlayView *overlay = [[OverlayView alloc]
initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
picker =
[[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.navigationBarHidden = NO;
picker.toolbarHidden = YES;
// Device's screen size (ignoring rotation intentionally):
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
float cameraAspectRatio = 4.0 / 3.0;
float imageWidth = floorf(screenSize.width * cameraAspectRatio);
float scale = ceilf((screenSize.height / imageWidth) * 10.0) / 10.0;
picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformIdentity, 2, 2);
picker.cameraOverlayView = overlay;
picker.allowsEditing = NO;
UIPinchGestureRecognizer *pinchRec = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(zoom:)];
[overlay addGestureRecognizer:pinchRec];
overlay.image =image;
[self.navigationController presentViewController:picker animated:NO completion:nil];
iOS 10.2 修复了这个问题!您现在可以使用cameraViewTransform
再次呈现相机之前的属性。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)