In my iphone app,I am showing images on a collection view. I fetch the images from urls,with urls I get the image size also. eg:- let\'s say there are two kinds of images la
For swift extend the flowlayout to you viewcontroller, if you need to show dynamic images on cell make variable which hold images name into your view contorller and use this:
let imageData = ["image1","image2","image3","image4"]
extension yourViewController: UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let photo = UIImage(named: imageData[indexPath.row])
return CGSize(width: (photo?.size.width)!, height: (photo?.size.height)!)
}
}