iOS:在iPhone相机预览中叠加

时间:2016-04-02 06:28:47

标签: ios objective-c camera overlays

我正在使用Camera API并调用相机。

我想在相机预览的顶部显示标题(用于标记)。标题是png图像。

有可能吗?任何帮助表示赞赏。

提前致谢。

2 个答案:

答案 0 :(得分:0)

您可以设置相机的叠加视图。 检查以下链接。它将帮助您解决问题。

https://stackoverflow.com/a/8101616/1850983

答案 1 :(得分:0)

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

        self.imgPickerCamera = [[UIImagePickerController alloc] init];
        self.imgPickerCamera.delegate = self;
        self.imgPickerCamera.allowsEditing = YES;

        self.imgPickerCamera.sourceType = UIImagePickerControllerSourceTypeCamera;


        self.imgPickerCamera.navigationBarHidden = NO;
        UIImageView *imageView = [[UIImageView alloc] initWithImage:@"<Your image>"];
        imageView.frame = <set frame>;

        //setting navigation bar
        self.imgPickerCamera.navigationController.navigationItem.titleView = imageView;

        // Insert the overlay: OverlayView is a UIView
        OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,1024) withImagePicker:self.imgPickerCamera];


        self.imgPickerCamera.cameraOverlayView = overlay;

        [self presentViewController:self.imgPickerCamera animated:YES completion:NULL];

    } else {

        [self showAlertWithOKButton:@"Error" message:@"Your device doesn't have camera."];
    }