【发布时间】:2017-08-03 15:06:30
【问题描述】:
我的UIImageView 在滚动或重新加载集合视图时不会显示为圆形 (collectionView.reloadData())。
看起来是这样的:
- 不四舍五入
- 四舍五入
该单元格具有多个图像视图,并且所有这些视图都被限制为使用facesContainer UIView 约束。
我试图在collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) 内部实现这段代码:
cell.facesContainer.layer.cornerRadius = (cell.facesContainer.layer.frame.width/2)
cell.facesGroupImageView.layer.cornerRadius = (cell.facesGroupImageView.layer.frame.width/2)
cell.facesGroupImageView.layer.masksToBounds = true
cell.facesGroupImageView.layer.borderColor = UIColor.black.cgColor
cell.facesGroupImageView.layer.borderWidth = 0.5
另外,我尝试在自定义单元类中,awakeFromNib() 方法中添加上面的代码 sn-p,但它不起作用。
为什么它不起作用?如何解决?
【问题讨论】:
-
你在 willdisplaycell 方法中尝试过吗
-
awakeFromNib中不存在约束。 -
看看这个帖子-解释和解决方法:stackoverflow.com/questions/32362934/…
标签: ios swift uicollectionview uicollectionviewcell cornerradius