将 UIlabel 添加到相机覆盖视图 uiimagepickercontroller Xcode objc

adding UIlabel to camera overlay view uiimagepickercontroller Xcode objc

我想在我的 UIImagePickerController 的自定义 OverlayView 之上添加一些 UILabel,但它似乎无法正常工作。

这是我的代码。

-(IBAction)getPhoto:(id)sender{
picker = [[UIImagePickerController alloc] init];

picker.allowsEditing = NO;

picker.sourceType =  UIImagePickerControllerSourceTypeCamera ;
picker.showsCameraControls = NO;
self.picker.navigationBarHidden = YES;
self.picker.toolbarHidden = YES;

OverlayView = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,1024)];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(OverlayView.frame.size.height/2, OverlayView.frame.size.width/2, 30, 100)];
label.textColor = [UIColor whiteColor];
label.text = @"find Me";
[self.OverlayView addSubview:label];
[self.OverlayView bringSubviewToFront:label];
picker.cameraOverlayView = OverlayView;
CGSize screenSize = [[UIScreen mainScreen] bounds].size;   // 320 x 568

float scale = screenSize.height / screenSize.width*3/4;  // screen height divided by the pickerController height ... or:  568 / ( 320*4/3 )

CGAffineTransform translate=CGAffineTransformMakeTranslation(0,(screenSize.height - screenSize.width*4/3)*0.5);
CGAffineTransform fullScreen=CGAffineTransformMakeScale(scale, scale);
picker.cameraViewTransform =CGAffineTransformConcat(fullScreen, translate);
[self presentViewController: picker animated:YES completion:NULL];

}

概览出现,全屏但没有标签 任何想法

你的标签在屏幕外,检查它的框架

你可以像这样放置它,至少它是可见的

self.overlayView = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(self.overlayView.frame.size.width/2, self.overlayView.frame.size.height/2, 30, 100)];