在我的项目中,我有 uicolelctionview
和自定义单元格。在 collectionView:CellForItemAtIndexPath
我得到了自定义单元格
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionCell
并添加此代码
cell.personImage.layer.cornerRadius=(cell.bounds.size.height-10)/2
cell.personImage.layer.borderWidth=3
cell.personImage.layer.masksToBounds=true
我希望得到这种类型的 View :
但一些细胞看起来像这样:
我必须 reloatData 才能获得当前的单元格 View 。
仍然无法理解为什么我会得到这个错误
最佳答案
您可以尝试使用以下代码设置动态角半径:
cell.personImage.layer.cornerRadius = cell.personImage.frame.width / 2.0
希望这可以帮助 :)
关于ios - UICollectionView 单元格绘图问题 swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33180379/