AVCaptureVideoPreviewLayer错误的帧捕获

时间:2013-05-13 10:00:24

标签: ios camera avfoundation

我有代码:

    previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[previewLayer setBackgroundColor:[[UIColor blackColor] CGColor]];
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
CALayer *rootLayer = [self.previewView layer];
[rootLayer setMasksToBounds:NO];
[previewLayer setFrame:CGRectMake([rootLayer bounds].origin.x, [rootLayer bounds].origin.y-20, [rootLayer bounds].size.width, [rootLayer bounds].size.height+40)];
[rootLayer addSublayer:previewLayer];

[previewLayer setBounds:previewLayer.frame];
[session startRunning];

当我开始捕捉图像时,飞溅白色视图在20px(状态栏高度)上移至顶部。并且snaped图片有错误的框架(-20到顶部,20到向下或在顶部是正确的,-20px向下)。实际的previewImage框架是

CGRectMake(15, 59, 290, 200).

现在它在帧CGRect中捕获图像(白色飞溅视图)=(15,59,290,170)。但是,snaped图像具有类似CGRect =(15,59,290,230)的帧。我做错了什么?请帮忙..

0 个答案:

没有答案