Can a VisualEffect (Blur) be added to a UIImageView using a IBDesignable class? (I've search all over and found nothing so far) I've tried adding it a layer.addSublayer(layer: CALayer) but there is not CALayer for visual effect
You can try making a subclass of UIImageView like the following:
@IBDesignable
class Blur: UIImageView {
@IBInspectable var blurImage:UIImage?{
didSet{
updateImage(blurImage!)
}
}
func updateImage(imageBlur:UIImage){
let imageToBlur:CIImage = CIImage(image: imageBlur)!
let blurFilter:CIFilter = CIFilter(name: "CIGaussianBlur")!
blurFilter.setValue(imageToBlur, forKey: "inputImage")
let resultImage:CIImage = blurFilter.valueForKey("outputImage")! as! CIImage
self.image = UIImage(CIImage: resultImage)
}
}
You will have to play around with it to get it the way you want.
More information about CoreImageFilter
can be found here