I have used UICollection view to show items in grid layout.
For data source I have use 5*5 dimensional array.
And also I am returning 5 for numberOfItems in
It works for me.
collectionView.reloadData() collectionView.collectionViewLayout.invalidateLayout()
It comes because of the cache of the Cell's Autolayout when reloadData.