so the angleAtExtreme =0 -theAngleOfTheLastItem1 = - collectionView.numberOfItemsInSection(0) * anglePerItem
items in collection spin within a scope of angle (angleAtExtreme,0),they spin by the contentOffSet.x,contentOffSet.x is within a scope of (0,contentSize.width - collectionView.bounds.size.width)
anchorPoint for the center of the layer is (0.5,0.5),so the 0.5 means the middle
Someone who knows how to center the entire array? So that the center item shows up first. Iâm trying to use collectionView.scrollToItem but with no success. It crashes in layoutAttributesForItem with âout of rangeâ -exceptionâŚ
I found out the answer myself. I had to set the contentView.offset.x to whatever value is corresponding to the item I want to view, like so:
if !is_init {
is_init = true
collectionView!.contentOffset.x = CGFloat(itemWidth*index-someOffset)
}
Replace CGRectGetWidth(collectionView!.bounds) with itemSize.width
else youâll receive error in angles calculation. it will be small and almost invisible for the eye. But it will be there. Spend about 3 hours figuring it out. I have collection view with 200 elements and was working with content offset to scroll to proper element. With your code positioning wasnât precise until i made the improvements above.
Anyway thank you for this tutorial. It helps a lot.
Unfortunately this example project no longer works. I wanted to test run the project to get an overview of functionality before diving into the tut but Swift 3 conversion failed and there were a number of other errors.
I solved all of the errors and warnings and the app runs to simulator but it will never display the actual collectionview. I added print statements to ânumberOfItemsâ and âcellForItemâ and it never calls âcellForItemâ function, while it does call ânumberOfItemsâ. Any ideas here? Anyone else able to download and get this working?
This tutorial is more than six months old, so questions regarding it are no longer supported for the moment. We will update it as soon as possible. Thank you! :]