0
我試圖在AVCaptureVideoPreviewLayer
之上創建覆蓋圖。以編程方式在AVCaptureVideoPreviewLayer上添加UIButton
我嘗試以下,但結果不是我所期待的按鈕的標題是不可見的:
let previewLayer: AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer(session: self.avCaptureSession)
previewLayer.frame = self.view.layer.frame
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
self.view.layer.addSublayer(previewLayer)
//Add Button
let captureButton = UIButton(frame: CGRectMake(0, 0, 100 , 100))
captureButton.backgroundColor = UIColor.grayColor()
captureButton.setTitle("Capture", forState: .Normal)
captureButton.setTitleColor(UIColor.redColor(), forState: .Normal)
captureButton.addTarget(self, action: "actionCapture:", forControlEvents: .TouchDragInside)
previewLayer.addSublayer(captureButton.layer)
這是當前狀態的屏幕截圖:
結果是什麼?你能告訴我們一個截圖嗎? – the4kman
@ the4kman我添加了屏幕截圖。 – Cloy