Q:

round image in swift

I'm trying to make an image round. I always used maskCircle but this time it does not work. I wrote the code in UICollectionViewCell's awakeFromNib and I can not use viewDidLayoutSubviews since I'm dequeueing the cell in cellForItemAt function. So this is the code: 
@IBOutlet weak var storeLogo: UIImageView!
override func awakeFromNib() {
    super.awakeFromNib()
    storeLogo.maskCircle()
    storeLogo.clipsToBounds = true
}

and the imageView looks like this: 
imageView
edit: 
it seemed to work fine, but i have the problem again.
this is the code in awakeFromNib now: 
    super.awakeFromNib()
    storeLogo.clipsToBounds = true
    storeLogo.layer.cornerRadius = storeLogo.frame.width / 2

    let gradient = CAGradientLayer()
    gradient.frame = CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: 55, height: 55))
    gradient.startPoint = CGPoint(x: 0, y: 1)
    gradient.endPoint = CGPoint(x: 1, y: 0)
    gradient.colors = [Color.storeName?.cgColor, Color.idTint?.cgColor]

    let shape = CAShapeLayer()
    shape.lineWidth = 2
    let radius: CGFloat = 27
    shape.path = UIBezierPath(roundedRect: CGRect(x: -2.5, y: -14, width: 2.0 * radius, height: 2.0 * radius), cornerRadius: radius).cgPath
    shape.position = CGPoint(x: self.frame.midX - radius, y: self.frame.midY - radius)
    shape.strokeColor = UIColor.black.cgColor
    shape.fillColor = UIColor.clear.cgColor
    gradient.mask = shape

    self.storeLogo.layer.addSublayer(gradient)

and the image is not round as you can see in this image: imageView
i
i don't know why the image is not a circle now. any idea?!

A:

If you want to do round clip on UIImageView set cornerRadius of UIImageView.
storeLogo.layer.cornerRadius = storeLogo.frame.width / 2
storeLogo.clipsToBounds = true

