I created the same component that is currently available in the UltraVisual iOS app for viewing recordings in animations such as parallax . See the GIF image below for more information. I want the same animation as in this video.
For this, I found two GitHub URLs, which is almost the same, but it does not match the same animation that was used in the UltraVisual iOS application. For more information, please find below two URLs for this.
URL: https://github.com/fdzsergio/SFFocusViewLayout/tree/2.0.0
URL: https://github.com/RobotsAndPencils/RPSlidingMenu
Problem:
Now I am faced with the problem of how to compress a focused image, given that the lower part remains stationary. The first focused image should be compressed from above (the lower part remains stationary), and at the same time, the next image will be focused, given that the upper part of the second image remains stationary.
Current Code:
- (void)prepareLayout { NSMutableArray *cache = [NSMutableArray array]; NSInteger numberOfItems = [self.collectionView numberOfItemsInSection:0]; // last rect will be used to calculate frames past the first one. We initialize it to a non junk 0 value CGRect frame = CGRectZero; CGFloat y = 0; CGFloat footerTop = 0; for (NSUInteger item = 0; item < numberOfItems; item++) { NSIndexPath *indexPath = [NSIndexPath indexPathForItem:item inSection:0]; UICollectionViewLayoutAttributes *attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath] ; // Important because each cell has to slide over the top of the previous one attributes.zIndex = item; // Initially set the height of the cell to the standard height CGFloat height = self.standardHeight; if (indexPath.item == self.currentFocusedItemIndex) { // The featured cell CGFloat yOffset = self.standardHeight * self.nextItemPercentageOffset; y = self.collectionView.contentOffset.y - yOffset; //y = yOffset - self.standardHeight * self.nextItemPercentageOffset; height = self.focusedHeight; //*********CURRENTLY WORKING ON THIS LINE TO ACHIEVE THE REQUIRED ANIMATION ****************** //attributes.transform = CGAffineTransformTranslate(attributes.transform, 0, -self.collectionView.contentOffset.y+self.dragOffset); //Solution might be here⦠} else if (indexPath.item == (self.currentFocusedItemIndex + 1) && indexPath.item != numberOfItems) { // The cell directly below the featured cell, which grows as the user scrolls CGFloat maxY = y + self.standardHeight; height = self.standardHeight + MAX((self.focusedHeight - self.standardHeight) * self.nextItemPercentageOffset, 0); y = maxY - height; //attributes.transform = CGAffineTransformTranslate(attributes.transform, 0, -self.collectionView.contentOffset.y+self.dragOffset); } else { y = frame.origin.y + frame.size.height; //attributes.transform = CGAffineTransformTranslate(attributes.transform, 0, -self.collectionView.contentOffset.y+self.dragOffset); } frame = CGRectMake(0, y, self.collectionView.frame.size.width, height); attributes.frame = frame; [cache addObject:attributes]; y = CGRectGetMaxY(frame); if (item == numberOfItems-1) { footerTop = CGRectGetMaxY(frame); } }; for (NSUInteger item = 0; item < numberOfItems; item++) { if (item == 0) { footerTop = footerTop + self.focusedHeight; } else { footerTop = footerTop + self.standardHeight; } } CGSize footerSize = [self footerReferenceSizeInSection:0]; if (footerSize.height > 0) { UICollectionViewLayoutAttributes *footerAttributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:UICollectionElementKindSectionFooter withIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]]; footerAttributes.zIndex = 0; footerAttributes.frame = CGRectMake(0, footerTop, footerSize.width, footerSize.height); self.footerAttributes[0] = footerAttributes; } self.cachedLayoutAttributes = [cache copy]; }
I changed the existing code ( https://github.com/fdzsergio/SFFocusViewLayout/tree/2.0.0 ) SFFocusLayout , and here is the code on which I have made changes so far, For this I mentioned a comment in the code where I feel that the solution lies, but is unable to succeed, because I have been fighting it for 3 to 4 days.
Please help me and thanks in advance.

ios objective-c uicollectionviewlayout uiviewanimation parallax
Gaurang makwana
source share