I'm new to Swift. I have created blurred UI in Sketch using Gaussian blur effect:
Now I want to implement this effect in UIImageView.
It is possible to use visual effect with blur or CIFilter to achieve same effect? (I've tried but didn't get it. May be I'm missing something)
Update:
Ok.. Thnks to @firstinq. I opened his link and realised that I was using kCIInputRadiusKey instead of inputRadius. Now I'm succeed in simulator but in real iOS device, it's still messed.
Here is the screenshot in simulator(iPhone SE):
But in real iOS device(iPhone SE):
Here is my code for blurring image:
func applyBlurEffect(image: UIImage) -> UIImage{
let imageToBlur = CIImage(image: image)
let blurfilter = CIFilter(name: "CIGaussianBlur")
blurfilter?.setValue(imageToBlur, forKey: "inputImage")
blurfilter?.setValue(13.4, forKey: "inputRadius")
let resultImage = blurfilter?.value(forKey: "outputImage") as! CIImage
let blurredImage = UIImage(ciImage: resultImage)
return blurredImage
}
I'm using two images in collectionView item. One image is blurred, And above it, another is fully visible. Blurred image is 125x125 sized (Gaussian blur will reduce this size). And visible image is 50x50 sized. Both images has corner radius to make them circular.