右栏图片被切断。比如右边的粉色狮子应该是基本对称的,但显然不是。这就是我配置 imageCell 的方式。
func configureCellWithImage(image: Image){
let iV = self.imageView
iV.setImageWithURL(image.thumbURL)
if(image.aspectRatio < 1.62){
iV.contentMode = UIViewContentMode.ScaleAspectFit
}else{
iV.contentMode = UIViewContentMode.ScaleAspectFill
}
}
这就是我返回单元格大小的方式。
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
let size = CGSize.init(width: screenSize.width/2 - 1, height: screenSize.width/2 * 1.62 - 1)
return size
}
感谢帮助。谢谢。
编辑:
我不知道为什么 UIView 的宽度是 201。它应该是 159。我如何访问这个 View ?我应该只有 CollectionView、imageCell 和 UIImageView。
最佳答案
尝试增加 Storyboard Collection View “部分插入”中右侧属性的值
关于ios - UICollectionView 单元格大小调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37717260/