问题
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];
回答1:
Please add this line to your code.
cell.productImage.contentMode = .scaleAspectFit
来源:https://stackoverflow.com/questions/50558996/uicollectionviewcell-is-square-but-image-is-rectangle