2014-04-03 1 views
2

AVCaptureVideoPreviewLayer에 UIButton 또는 다른 유형의 버튼을 추가하고 싶습니다. 여기 AVCaptureVideoPreviewLayer에 UIButton을 추가 하시겠습니까?

내가 시도 것입니다 :

[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가 시작되지 않은 경우에도. 그러나 그 뷰에 하위 뷰를 추가 할 수는 없습니다.

+0

왜 videoPreviewLayer의 containerView.layer의 버튼을 추가하지 마십시오? – Chris

+0

그럴 수 있습니다. 어떻게해야합니까? videoPreviewLayer.containerview.layer가 존재하지 않습니다. – DCIndieDev

답변

0
파티에 늦게 리틀

,하지만 난 비슷한 작업을했습니다, 그래서 내가 공유하고자합니다 :

UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
btn.frame = CGRectMake(200, 200, 100, 50); 
[btn setTitle:@"Hello, world!" forState:UIControlStateNormal]; 
[btn setBackgroundColor:[UIColor blueColor]]; 
[btn becomeFirstResponder]; 
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, btn); 
[self.view addSubview:btn];