Więc staram się symulować papieru krotnie typu origami podczas dodawania i usuwania komórek podobnie aplikacji peek Kalendarz: Jak symulować krotnie papieru podczas wstawiania i usuwania wierszy w UITableView
Dostałem całkiem blisko ta funkcjonalność przez podklasowanie UITableView i przesłanianie insertRowsAtIndexPaths: withRowAnimation: i deleteRowsAtIndexPaths: withRowAnimation:
Jednak teraz nie mogę sprawić, że animacja wygląda dobrze. Poniżej znajduje się mój obecny kod - chciałbym pomóc w pokonaniu tej ostatniej przeszkody (a może jest zupełnie inne podejście, takie jak dodanie tableview do tableviewcell).
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths
withRowAnimation:(UITableViewRowAnimation)animation
{
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
float duration = .30;
int i = 0;
for (NSIndexPath *indexPath in indexPaths) {
__block UITableViewCell *cell = [super cellForRowAtIndexPath:indexPath];
if (cell) { // If indexPath isn't visible we'll get nil here
//even cells flip up while odd cells flip down
if(i % 2 ==0){
cell.layer.anchorPoint = CGPointMake(.5, 0);
//start row off by rotating 90 degrees
__block CATransform3D t = CATransform3DIdentity;
t = CATransform3DTranslate(t, 0, -cell.bounds.size.height/2, 0);
t = CATransform3DRotate(t, hn_radians(90), 1, 0, 0);
t.m34 = -1.0/(cell.layer.bounds.size.height * 4.6666667);
cell.layer.transform = t;
//flip up
[UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
t = CATransform3DIdentity;
t = CATransform3DTranslate(t, 0, -cell.bounds.size.height/2, 0);
cell.layer.transform = t;
NSLog(@"");
} completion:^(BOOL finished) {
cell.layer.transform = CATransform3DIdentity;
cell.layer.anchorPoint = CGPointMake(.5, .5);
}];
}
else{
cell.contentView.layer.anchorPoint = CGPointMake(.5, 1);
//start row off by rotating 90 degrees
__block CATransform3D t = CATransform3DIdentity;
t = CATransform3DTranslate(t, 0, -cell.contentView.bounds.size.height * 0.5f, 0);
t = CATransform3DRotate(t, hn_radians(-90), 1, 0, 0);
t.m34 = -1/500.f;
cell.contentView.layer.transform = t;
//flip down
[UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
t = CATransform3DIdentity;
t = CATransform3DTranslate(t, 0, cell.contentView.bounds.size.height * 0.5f, 0);
cell.contentView.layer.transform = t;
} completion:^(BOOL finished) {
//reset anchor and transform
cell.contentView.layer.transform = CATransform3DIdentity;
cell.contentView.layer.anchorPoint = CGPointMake(.5, .5);
}];
}
i++;
}
}
}
https://github.com/mrzedese/MPFoldTransition –
Już sprawdziłem ten projekt - nie robi tego, co chcę. Jest dobre dla pojedynczego złożenia przejścia z jednego widoku do drugiego, ale nie dla dodawania/usuwania wierszy w widoku tabeli i nie obsługuje wielokrotnych fałd. – MweyaMutsvene
https://github.com/honcheng/PaperFold-for-iOS Wypróbuj raz. –