0

我环顾四周,找不到答案,如果已经问过这个问题,我深表歉意。

我想创建一个工具栏形状的视图,虽然不是一个实际的工具栏,因为侧边菜单不能使用 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 比较陌生,所以代码示例会很有帮助!提前致谢!

4

1 回答 1

1

UIVisualEffectView在视图层次结构顶部添加一个。(将您的视频图层添加到另一个视图的图层,然后将其UIVisualEffectView放在该视图的顶部。)

于 2015-06-27T15:44:21.520 回答