MPFoldTransition
これは、 's を使用して完全に可能transitionFromView: toView:...
です。必要に応じてリンクできるサンプルプロジェクトを作成しましたが、実際には次のようになります。
- (void)addNewTableCellToIndexPath:(NSIndexPath *)indexPath {
// Add the new object to the datasource and reload the row
[dataSourceArray insertObject:@"New" atIndex:indexPath.row];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
//setup temporary cell
UITableViewCell *fromCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
[fromCell setBackgroundColor:[[self.tableView cellForRowAtIndexPath:indexPath] backgroundColor]];
//setup cell to animate to
UITableViewCell *toCell = [self.tableView cellForRowAtIndexPath:indexPath];
[toCell.textLabel setText:dataSourceArray[indexPath.row]];
//add fold animation to the cells create above
[MPFoldTransition transitionFromView:fromCell
toView:toCell
duration:0.4
style:MPFoldStyleUnfold
transitionAction:MPTransitionActionNone
completion:^(BOOL finished) {
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}];
}
Aboutは、インデックスパスを引数として取る関数です。折り畳み遷移でセルを追加するインデックスパスを送信すると、残りのセルを下にシフトしながら、折り畳むための空白の一時セルがテーブルに作成されます。これは完璧ではありません。主な理由は、フォールドの持続時間と完全に一致するようにUITableViewRowAnimation
の持続時間を変更する方法がわからないためです。
いずれにせよ、これはあなたを動かすのに十分なはずです。お役に立てれば!