Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move and Scale not working when overlayview set to camera

I am trying to add overlay view and move & scale functionality to captured image, but I am not able to do this because of overlay view.

Here is my code:

-(void)showOverlayCamera
{

UIImagePickerController *pickerObj = [[UIImagePickerController alloc] init];
pickerObj.delegate = self;
pickerObj.allowsEditing = YES;
pickerObj.sourceType = UIImagePickerControllerSourceTypeCamera;

// creating overlayView
UIView* overlayView = [[UIView alloc] initWithFrame:self.view.bounds];
UIImageView *logoImgView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"logo.png"]];
logoImgView.frame=CGRectMake(10, 10, 100, 20);
[overlayView addSubview:logoImgView];

//add lable in overlay view
UILabel *headerLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, logoImgView.frame.origin.y+logoImgView.frame.size.height+10, 250, 40)];
headerLabel.text=@"New Scan";
headerLabel.textColor=[UIColor whiteColor];
headerLabel.font=[UIFont fontWithName:@"Helvetica-Bold" size:40];
headerLabel.backgroundColor=[UIColor clearColor];
[overlayView addSubview:headerLabel];

//add square image in overlay view
squareImgView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cameraBorder.png"]];
squareImgView.frame=CGRectMake(60, headerLabel.frame.origin.y+headerLabel.frame.size.height+20, 200, 200);
[overlayView addSubview:squareImgView];

//adding lable in overlay view
UILabel *instructionLabel=[[UILabel alloc]initWithFrame:CGRectMake(60, squareImgView.frame.origin.y+squareImgView.frame.size.height+5, 250, 60)];
instructionLabel.numberOfLines=2;
instructionLabel.text=@"Focus your mole in the center of square";
instructionLabel.textColor=[UIColor whiteColor];
instructionLabel.font=[UIFont fontWithName:@"Helvetica" size:20];
instructionLabel.backgroundColor=[UIColor clearColor];
[overlayView addSubview:instructionLabel];

[overlayView.layer setOpaque:NO];
overlayView.opaque = NO;
//adding overlay view on camera
[pickerObj setCameraOverlayView:overlayView];
[self presentViewController:pickerObj animated:YES completion:nil];
}
like image 931
Prashant Chaudhari Avatar asked Aug 02 '13 08:08

Prashant Chaudhari


2 Answers

Finally I am getting answer. I create UIView subclass for overlayview and override following method, it will ignore touches on overlayView.

-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{

return NO;
}
like image 198
Prashant Chaudhari Avatar answered Nov 14 '22 23:11

Prashant Chaudhari


Try making overlay an instance of a UIView subclass with overridden hitTest: withEvent:. If you don't want it or any of its subviews to receive touches, it would be like this:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    return nil;
}
like image 36
johnyu Avatar answered Nov 15 '22 00:11

johnyu