如何让UIViewcontroller在swift中透明? clear()不起作用

时间:2016-04-29 12:03:30

标签: swift uiviewcontroller

我有一个问题:如何使UIviewcontroller透明化。我想将iPhone的背景图像作为背景图像作为我的应用程序

我想创建一个类似于这个界面的界面:Creating a blurring overlay view

代码效果很好:

if !UIAccessibilityIsReduceTransparencyEnabled() {
        self.view.backgroundColor = UIColor.clearColor()

        let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
        let blurEffectView = UIVisualEffectView(effect: blurEffect)
        //always fill the view
        blurEffectView.frame = self.view.bounds
        blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]

        //self.view.addSubview(blurEffectView) //if you have more UIViews, use an insertSubview API to place it where needed
        self.view.insertSubview(blurEffectView, atIndex: 0)
    }
    else {
        self.view.backgroundColor = UIColor.clearColor()
    }

但在self.view.backgroundColor = UIColor.clearColor()之后,我的应用程序的背景总是白色......背景不透明......

我想让应用程序的背景透明,以显示iPhone的图像背景,怎么做?

PS:我有第二个解决方案,将iPhone的背景图像显示为我的应用程序的背景图像,它是获取iPhone的背景图像...但是如何在启动应用程序之前获取iPhone的背景图像?

谢谢你们所有人。

0 个答案:

没有答案
相关问题