xcode 如何添加 uiimagepickerview 自定义叠加层

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9900445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:48:11  来源:igfitidea点击:

How to add a uiimagepickerview custom overlay

iphoneiosxcodeoverlayuiimagepickercontroller

提问by Desmond

i will like to add a custom overlay on the UIImagepickerview with some custom buttons.

我想在 UIImagepickerview 上添加一个带有一些自定义按钮的自定义叠加层。

will appreciated if anyone could show me a link or 2 to the tutorial.

如果有人可以向我展示教程的链接或 2,我将不胜感激。

thanks

谢谢

回答by g_low

Here is a PhotoPicker sample code project:

这是一个 PhotoPicker 示例代码项目:

https://developer.apple.com/library/ios/#samplecode/PhotoPicker/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010196

https://developer.apple.com/library/ios/#samplecode/PhotoPicker/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010196

The gist is to make your own class with a .xib file with a custom toolbar, and then add that as a custom overlay. Make sure that you set your UIImagePickerController's showCameraControls property to NO.

要点是使用带有自定义工具栏的 .xib 文件创建您自己的类,然后将其添加为自定义叠加层。确保将您UIImagePickerController的 showCameraControls 属性设置为 NO。

Assuming that you have created a OverlayViewControllerclass that is a UIImagePickerControllerDelegateand has a UIImagePickerControllerpicker:

假设您创建了一个OverlayViewController类,UIImagePickerControllerDelegate并且有一个UIImagePickerController选择器:

self.picker.showsCameraControls = NO;

In addition (for iPhone), you will find that there is a difference in aspect ratio between the live camera picture and the iPhone screen size, which will give you a bar at the bottom of your screen. This can be fixed by doing a translation and scale:

另外(对于iPhone),你会发现实况摄像头图片和iPhone屏幕尺寸之间的纵横比存在差异,这会在你的屏幕底部显示一个栏。这可以通过进行翻译和缩放来解决:

CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 25.0);
self.picker.cameraViewTransform = CGAffineTransformScale(translate, 480.0/430.0, 480.0/430.0);
self.picker.cameraOverlayView = self.view;

回答by Igor

Apple has a good tutorial, how to customize uiimagepickerview. His name is PhotoPicker

苹果有很好的教程,如何自定义uiimagepickerview。他的名字是PhotoPicker