My UICollectionView
is stretching the images inside the cells.How to fit the image inside the cell?
Asked
Active
Viewed 990 times
0

Jas
- 3,207
- 2
- 15
- 45
-
share your image setting code ??? – Muhammad Raheel Mateen Feb 23 '16 at 11:33
-
check this ... http://blogs.innovationm.com/image-handling-in-ios/ – Bhavin Bhadani Feb 23 '16 at 11:47
2 Answers
2
Use following for setting content mode of UIImage
imageView.contentMode = UIViewContentModeScaleAspectFit;

Ashish P.
- 848
- 5
- 12
-
-
yes.. use UIViewContentModeScaleAspectFill instead of UIViewContentModeScaleAspectFit but you also need to set imageView.clipsToBounds = YES; – Ashish P. Feb 23 '16 at 12:39
-
0
For center cropping of image
imageView.contentMode = UIViewContentModeCenter;
you can also try this solution to best fit your need

Community
- 1
- 1

Sourabh Sharma
- 8,222
- 5
- 68
- 78