构建方案后,按钮消失

时间:2018-08-19 17:52:43

标签: ios swift button camera blur

在我的菜单中,我有六个按钮(无需编码即可链接到其他ViewController)。作为背景,我想要一个模糊的相机视图(而不是简单的白色背景)。

我的问题: 当我启动该应用程序时,它仅显示模糊的相机视图(如我所愿),但是按钮丢失。

这是我的代码:

import UIKit
import AVFoundation

class ViewControllerBlurrHome: UIViewController {

    let session: AVCaptureSession = AVCaptureSession()

    override func viewDidLoad() {
        super.viewDidLoad()
    }



    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        session.sessionPreset = AVCaptureSession.Preset.high

        if let device = AVCaptureDevice.default(for: AVMediaType.video) {
            do {
                try session.addInput(AVCaptureDeviceInput(device: device))

            } catch {
                print(error.localizedDescription)
            }

            let previewLayer = AVCaptureVideoPreviewLayer(session: session)

            self.view.layer.addSublayer(previewLayer)
            previewLayer.frame = self.view.layer.bounds

        }



        session.startRunning()

        let blur = UIBlurEffect(style: .regular)
        let blurView = UIVisualEffectView(effect: blur)
        blurView.frame = self.view.bounds
        blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        self.view.addSubview(blurView)

//"Back"
    }
    @IBAction func unwindFromSources(segue: UIStoryboardSegue){

    }
// ShareButton
    @IBAction func sharePressed(_ sender: Any) {
        let activityVC = UIActivityViewController(activityItems: ["enter App Link here"], applicationActivities: nil)
        activityVC.popoverPresentationController?.sourceView = self.view
        self.present(activityVC, animated: true, completion: nil)
    }
}

这是我的菜单的样子: image

就像这样:image2

0 个答案:

没有答案