Pra*_*ari 8 iphone uiimagepickercontroller ios
我正在尝试添加叠加视图并将功能移动和缩放到捕获的图像,但由于叠加视图,我无法执行此操作.
这是我的代码:
-(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];
}
Run Code Online (Sandbox Code Playgroud)
最后我得到了答案.我为overlayview创建了UIView子类并覆盖了以下方法,它将忽略overlayView上的触摸.
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
return NO;
}
Run Code Online (Sandbox Code Playgroud)
尝试使用覆盖的 hitTest: withEvent: 使 UIView 子类的实例覆盖。如果您不希望它或其任何子视图接收触摸,则应如下所示:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
return nil;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
501 次 |
| 最近记录: |