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