casillas
casillas

Reputation: 16813

UICollectionViewCell is square, but image is rectangle

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

Upvotes: 1

Views: 467

Answers (1)

Khushbu
Khushbu

Reputation: 2430

Please add this line to your code.

cell.productImage.contentMode = .scaleAspectFit

Upvotes: 2

Related Questions