我正在使用Apple的AVCam示例,我正在尝试修改布局以使用iPad。
我正试图让状态栏始终存在,但无论何时启用它,(我认为是videoPreviewView
及其viewLayer
)都处于状态栏的状态。所以我需要将它降低20px以便为状态栏腾出空间,但我不确定如何。
AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[[self captureManager] session]];
UIView *view = [self videoPreviewView];
CALayer *viewLayer = [view layer];
[viewLayer setMasksToBounds:YES];
CGRect bounds = [videoPreviewView bounds];
[[self view] setBounds:bounds];
newCaptureVideoPreviewLayer.bounds = bounds;
[newCaptureVideoPreviewLayer setFrame:bounds];
答案 0 :(得分:0)
将其放在UIView *view = [self videoPreviewView];
CGPoint viewCenter = view.center;
viewCenter = CGPointMake(viewCenter.x, viewCenter.y - 20)
view.center = viewCenter;
答案 1 :(得分:0)
将这个添加到AdamG的答案就行了,不知道为什么或者它是否是一个可行的解决方案。有人关心进来吗?
CGPoint viewCenter = view.center;
viewCenter = CGPointMake(viewCenter.x, viewCenter.y + 20);
view.center = viewCenter;
CGRect temp = view.frame;
temp.size.height += -20;
view.frame = temp;