I'm using a UICollectionview
with a circular layout. I'm trying to calculate the contentOffset
per item but with the circular layout the full contentsize
does not seem match the content.
Is there any way I can get the offset for an item by it's indexPath
or at least the correct (397) value for the last item's in the collectionview
? I got these values by testing and printing the contentoffset
but I would like to calculate these numbers (33 and 397) by code without having to scroll.
So is there a way to calculate a cell's contentoffset
(?) inside the collectionview
by it's indexPath
? Thanks!
I found the problem, the contentsize
of the scrollview
is the size of the content + the size of the uicollectionview's
frame. That was the reason the contentSize
returned a larger size than the actual content was.
so: (contentSizeX - collectionviews frame X) / cells = contentOffset per item (780 - 383) / 12 => 33
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.