I am trying to blur the main screen (tab controller) on my help screen using the code given below. The screen appears properly but the border of my help screen gets a black shadow on all the four sides. This happens only when my main screen is a tab bar controller, if my main screen is normal view controller the black shadow doesn't appears it works fine.
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0)
self.view.layer.renderInContext(UIGraphicsGetCurrentContext())
var backgroundImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()
var rec: CGRect = CGRectMake(0, 0, width, height)
UIGraphicsBeginImageContext(rec.size)
backgroundImage.drawInRect(rec)
var picture1: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
var imageData: NSData = UIImagePNGRepresentation(picture1)
var back: UIImage = UIImage(data: imageData)!
var context: CIContext!
var currentFilter: CIFilter!
context = CIContext(options: nil)
currentFilter = CIFilter(name: "CIGaussianBlur")
let beginImage = CIImage(image: back)
currentFilter.setValue(beginImage, forKey: kCIInputImageKey)
let cgimg = context.createCGImage(currentFilter.outputImage, fromRect: rec)
let processedImage = UIImage(CGImage: cgimg)
back = processedImage!
var mainstoryboard = UIStoryboard(name: "Main", bundle: nil)
var s = mainstoryboard.instantiateViewControllerWithIdentifier("YAFullNameHelpScreen") as! YAGetMeToHelpScreenVC
s.view.backgroundColor = UIColor(patternImage: back)
self.presentViewController(s, animated: true, completion: nil)I have added the screenshot below:
I have achevied the screen blurring effect by adding the following code on the help screen button IBAction
let rect: CGRect = self.view.bounds
UIGraphicsBeginImageContext(rect.size)
self.view.layer.renderInContext(UIGraphicsGetCurrentContext()!)
let backgroundImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()
let rec: CGRect = CGRectMake(-5, -4, width + 3, height + 2)
UIGraphicsEndImageContext()
UIGraphicsBeginImageContext(rec.size)
backgroundImage.drawInRect(rec)
let picture1: UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let imageData: NSData = UIImagePNGRepresentation(picture1)!
var back: UIImage = UIImage(data: imageData)!
var context: CIContext!
var currentFilter: CIFilter!
context = CIContext(options: nil)
currentFilter = CIFilter(name: "CIGaussianBlur")
let beginImage = CIImage(image: back)
currentFilter.setValue(beginImage, forKey: kCIInputImageKey)
let cgimg = context.createCGImage(currentFilter.outputImage!, fromRect: rec)
let processedImage = UIImage(CGImage: cgimg)
back = processedImage
let mainstoryboard = UIStoryboard(name: "MainStoryboard", bundle: nil)
let s = mainstoryboard.instantiateViewControllerWithIdentifier("HelpScreenVC") as! SIDHelpScreenVC
s.view.backgroundColor = UIColor(patternImage: back)/
self.presentViewController(s, animated: true, completion: nil)