가로 또는 세로보기 뷰 설정
- (UIView *)videoPreviewWithFrame:(CGRect)frame
{
videoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[self captureSession]];
[videoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
if ([videoPreviewLayer isOrientationSupported]) {
videoPreviewLayer.orientation = AVCaptureVideoOrientationLandscapeRight;
}
videoPreviewLayer.frame = frame;
UIView *tempView = [[UIView alloc] init];
[tempView.layer addSublayer:videoPreviewLayer];
tempView.frame = frame;
return tempView;
}
사용은 이렇게
// 레이어 설정
UIView *preView = [self videoPreviewWithFrame:CGRectMake(0, 0, 480, 320)];
[self.view addSubview:preView];
댓글
댓글 쓰기