 
 
 class MainViewController: UITabBarController {
-    var backImage: UIImage?
+    var backImage: UIImage!
+    var previousIndex: Int?
     
 
     override func viewDidLoad() {

    
    func tabBarController(_ tabBarController: UITabBarController,
                          didSelect viewController: UIViewController){
        if tabBarController.viewControllers?.index(of: viewController) == 3 {
            if let backImage = backImage {
                viewController.view.backgroundColor = UIColor(patternImage: backImage)
            }
            else {
                viewController.view.backgroundColor = UIColor.white
            }
        }


        UIGraphicsEndImageContext()
        return snapdImage!
    }
    
    func blurImage(targetImage: UIImage) -> UIImage {
        let ciImage = CIImage(image: targetImage)
        let filter = CIFilter(name: "CIGaussianBlur")!
        //filter.setDefaults()
        filter.setValue(ciImage, forKey: kCIInputImageKey)
        let resultImage = filter.value(forKey: kCIOutputImageKey) as! CIImage
        let context = CIContext()
        let cgImage = context.createCGImage(resultImage, from: resultImage.extent)!
        
        let blurredImage = UIImage(cgImage:cgImage)
        //let blurredImage = UIImage(ciImage: resultImage)
        return blurredImage
        
        

    }
        
    
    
//
//   
