右列圖片被截斷。例如,右邊的粉色獅子應該基本對稱,但顯然不是。這是我配置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.我將如何訪問這個觀點?我應該只有CollectionView,imageCell和UIImageView。
你確定,你的收藏視圖佈局'minimumInteritemSpacing'是1? – Johnykutty