简体   繁体   English

如何在ios应用程序的相机全屏视图上绘制图片?

[英]how to draw on top of the camera full screen view in an ios app?

I would like to place a compass, or an image on top of the camera view in my iOS app? 我想在我的iOS应用程序的相机视图顶部放置指南针或图像吗?

Background: I am creating an app, that would open the camera in the native side with is the iOS, then in the HTML side without using phone gap, or cordova. 背景:我正在创建一个应用程序,它将使用iOS在本机端打开相机,然后在HTML端打开相机,而无需使用电话间隙或cordova。 I am using Native bridging, i would like to place a moving compass on top of the camera view on my iOS app, what methods should i use? 我正在使用本机桥接,我想在我的iOS应用程序的摄像头视图上方放置一个移动的罗盘,我应该使用哪些方法? any helpful code? 任何有用的代码?

thank you 谢谢

Use the cameraOverlayView property of UIImagePickerController to set an overlay on top of camera. 使用UIImagePickerControllercameraOverlayView属性可以在相机顶部设置一个叠加层。 Check apple documentation for more details. 有关更多详细信息,请查阅Apple文档 You can add any UIView as the overlayview. 您可以将任何UIView添加为overlayview。

In order to use the magnetometer, you'll have to use CoreLocation and the following delegate method: 为了使用磁力计,您必须使用CoreLocation和以下委托方法:

- (void) locationManager:(CLLocationManager *)manager
             didUpdateHeading:(CLHeading *)newHeading

to rotate a UIView to point North: 旋转UIView以指向北:

float heading = newHeading.magneticHeading; //in degrees
float headingDegrees = (heading*M_PI/180); //assuming needle points to top of iphone. convert to radians
self.imageView.transform = CGAffineTransformMakeRotation(headingDegrees);

You might also find these questions useful: 您可能还会发现以下问题很有用:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM