我环顾四周找不到答案,如果已经提出这个问题,请道歉。
我想创建一个工具栏形状的视图,虽然不是实际的工具栏,因为侧面菜单无法使用iOS8的新实时模糊效果覆盖工具栏(FrostedSidebar),因此呈现的预览模糊了工具栏结束了。我的预览会话如下:
func beginSession() {
var err : NSError? = nil
captureSession.addInput(AVCaptureDeviceInput(device: captureDevice, error: &err))
if err != nil {
println("error: \(err?.localizedDescription)")
}
previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
self.view.layer.insertSublayer(previewLayer, atIndex: 0)
//self.view.lay
previewLayer?.frame = self.view.layer.bounds
captureSession.startRunning()
if captureSession.canAddOutput(stillImageOutput) {
captureSession.addOutput(stillImageOutput)
}
}
我尝试了以下内容但没有取得任何成功:
self.view.addSubview(topBar)
//UIApplication.sharedApplication().keyWindow?.addSubview(bottomBar)
previewLayer.bringSubviewToFront(topBar)
UIApplication.sharedApplication().keyWindow?.bringSubviewToFront(bottomBar)
self.topBar.addSubview(burgerBtn)
self.bottomBar.addSubview(cameraBtn)
我对swift相对较新,所以代码示例会非常有用! 提前谢谢!
答案 0 :(得分:0)
在视图层次结构的顶部添加UIVisualEffectView
。 (将您的视频图层添加到另一个视图的图层,然后将UIVisualEffectView
放在该视图的顶部。)