Posts

Showing posts from December 17, 2018

How to set Dynamic Height of UIImage in UICollectionView Like Pinterest in Swift

Image
up vote -1 down vote favorite I am trying to do layout like Pinterest uses for their image gallery, but the issue is that I'm returning the image height to size the cells and when the images have different heights it leaves spaces in the cells. I have walked through lot's of articles, but I have not found a simple solution. Is there any simple way we can do this? Thanks you for your time and help! Please see this image class ViewController: UIViewController { @IBOutlet var collectionVIew: UICollectionView! var imgData = [#imageLiteral(resourceName: "p1"),#imageLiteral(resourceName: "p2"),#imageLiteral(resourceName: "p3"),#imageLiteral(resourceName: "p4"),#imageLiteral(resourceName: "p5"),#imageLiteral(resourceName: "p6"),#imageLiteral(resourceName: