UICollectionViewCell is square, but image is recta

2019-07-25 23:04发布

I am using UICollectionView where cell's are almost square, but original image is rectangle. Therefore, when I display image as follows, it is getting cut.

Is there a way to handle this issue?

I am currently working on Objective-C but I am to see Swift solution as well.

cell.productImage content mode is Aspect Fill

cell.productImage.image = [cell.productImage.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

enter image description here

1条回答
Lonely孤独者°
2楼-- · 2019-07-25 23:21

Please add this line to your code.

cell.productImage.contentMode = .scaleAspectFit
查看更多
登录 后发表回答