Stworzyłem ten sam komponent, który obecnie jest dostępny w aplikacji UltraVisual
iOS do przeglądania rekordów w animacji takich jak efekty parallax
. Poniżej znajduje się załączony obraz GIF, aby uzyskać więcej informacji. Chcę tę samą animację, co w podanym adresie URL filmu.Ultravisual aplikacja iOS podobna do animacji za pomocą UICollectionViewLayout bez nakładania się obrazów
W tym celu znalazłem dwa adresy URL GitHub, które są prawie takie same, ale nie spełniają tej samej animacji, która była używana w aplikacji iOS na numer UltraVisual
. Aby uzyskać więcej informacji, znajdź poniżej dwa adresy URL dla tego samego.
URL: https://github.com/fdzsergio/SFFocusViewLayout/tree/2.0.0
URL: https://github.com/RobotsAndPencils/RPSlidingMenu
Problem:
Teraz jestem w obliczu problemu, w jaki sposób zmniejszyć obraz skupiony rozważa dolną część, która pozostaje statyczna. Pierwszy skupiony obraz powinien się skurczyć od góry (dolna część pozostaje statyczna) i jednocześnie następny obraz zostanie skupiony, biorąc pod uwagę drugi obraz, który pozostaje statyczny.
Aktualny Kod:
- (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];
}
ja nie zmieniło istniejącego kodu (https://github.com/fdzsergio/SFFocusViewLayout/tree/2.0.0) SFFocusLayout
biblioteki i tutaj jest kod, na którym dokonano zmian tak daleko. W tym celu wspomniałem o komentarzu w kodzie, w którym czuję, że rozwiązanie leży, ale nie mogę odnieść sukcesu, ponieważ mam problem z ostatnich 3 do 4 dni.
Proszę mi pomóc i dzięki z góry.
..i jest pytanie? –
Chcę tę samą animację, co w załączonym pliku .gif. @ LucaDavanzo –
Czy możesz poprawić swoje pytanie, aby dokładniej określić swój problem. –