I am currently using CALayerfor UIImageViewlike this:
let l: CALayer = imageView.layer
l.masksToBounds = true
l.cornerRadius = 20.0

I would like to get the following blurry effect as below:

I tried the following:
let blurEffect = UIBlurEffect(style: .light)
let visualEffectView = UIVisualEffectView(effect: blurEffect)
imageView.addSubview(visualEffectView)
and:
var visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .light))
visualEffectView.frame = staffImageView.bounds
imageView.addSubview(visualEffectView)
However, both results do not achieve the desired results.
Can anyone help with this? It seems pretty simple, but I just can't get it.
UPDATE:
I tried to play with the gradient, but didn't have much luck:
var maskLayer = CAGradientLayer()
maskLayer.frame = cell.imageView.bounds
let black = UIColor.white.cgColor
let clear = UIColor(white: 1, alpha: 0).cgColor
maskLayer.colors = [black, clear]
maskLayer.locations = [0.0, 0.10]
maskLayer.startPoint = CGPoint(x: 1, y: 0)
maskLayer.endPoint = CGPoint(x: 1, y: 1)
cell.imageView.layer.addSublayer(maskLayer)
Result:

source
share