Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TableView with image background and blur effect - swift

I have a little problem: I'd like to set an image to background in a TableViewController. I tried this:

class SquadreController: UITableViewController {

    override func viewDidLoad()
    {
        super.viewDidLoad()

        var sfondo = UIImage(named: "sfondo")
        self.view.backgroundColor = UIColor(patternImage: sfondo!)

    }

Then I give the blur effect to the view, like this:

let blur = UIBlurEffect(style: UIBlurEffectStyle.Light)
let blurView = UIVisualEffectView(effect: blur)
blurView.frame = self.view.bounds
view.addSubview(blurView)

But there is a big problem. I'm working in a TableView and the TableView, TableCell, NavigationItem, etc. have all disappeared after I apply the blur. Can someone help me?

Thanks a lot!

like image 398
Fabio Cenni Avatar asked Jul 28 '15 23:07

Fabio Cenni


1 Answers

Try using view.insertSubView(blurView, atIndex: 0) instead of view.addSubview(blurView) as! UIImageView

like image 64
Epic Defeater Avatar answered Nov 15 '22 03:11

Epic Defeater