Q:

UICollectionView cell drawing issues swift

In my porject I  have uicolelctionview and custom cell. In collectionView:CellForItemAtIndexPath I get the custom cell
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionCell

and add this code 
cell.personImage.layer.cornerRadius=(cell.bounds.size.height-10)/2
cell.personImage.layer.borderWidth=3
cell.personImage.layer.masksToBounds=true

I was hopping to get this type of view:

but some of cells appears like this:

and I have to reloatData to get current cell view.
Still cant understand why I get this bug

A:

You can try to set dynamic corner radius with the following code:
cell.personImage.layer.cornerRadius = cell.personImage.frame.width / 2.0

Hope this helps :)

