2
我想添加一个UIButton或其他类型的按钮到AVCaptureVideoPreviewLayer。添加UIButton到AVCaptureVideoPreviewLayer?
这是我曾尝试:
[self.view.layer addSublayer:_videoPreviewLayer];
UIButton * sButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 0, 300, 100)];
[sButton setBackgroundColor:[UIColor yellowColor]];
[sButton setTitle:@"Stop" forState:UIControlStateNormal];
[sButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_videoPreviewLayer addSublayer:sLabel.layer];
[_captureSession startRunning];
我也试图与其中加入的UIView类似的东西,即使AVCapture没有启动。然而,我无法为该视图添加子视图。
你为什么不加上videoPreviewLayer的containerView.layer按钮? – Chris
这可以工作。我怎么做? videoPreviewLayer.containerview.layer不存在。 – DCIndieDev