What is the difference between:
self.collectionView.contentSize.height
and self.collectionView.bounds.origin.y
?
The latter always seems to be smaller than the former?
Any clarifying sketches would be highly appreciated.
What is the difference between:
self.collectionView.contentSize.height
and self.collectionView.bounds.origin.y
?
The latter always seems to be smaller than the former?
Any clarifying sketches would be highly appreciated.
contentSize
is the size of the content, which is shown by scrolling. say you have 10 cell's sizing of 3600x1200. Then the content size will be 3600x1200. Bound will be the actual frame of the collectionview.
For more information
contentSize
is not direct property of UICollectionView
. It's derived from the UIScrollView
. check herehappy coding.
The value of self.collectionView.bounds.origin.y is 0. Because the bounds of an UIView is the rectangle which is expressed by its own co-ordinate system. Refer to Cocoa: What's the difference between the frame and the bounds?
self.collectionView.contentSize.height = contentSize of scrollview
Let you have a collection view(scroll vertically) whose frame is (0,64,320,504) and size of its each cell is (100,100) and you have 20 item. So, each row of collection view contain 3 cell. Now, to fit 20 item in collectionview 7 row will generate and we can see all those item by scrolling vertically.
Actual size of collectionview is (320,504) and the contentsize is (320,700).
Note:Assuming collectionview is scrolls vertically and there is no space between two row.