如何在Xamarin iOS中将UITableViewCell从底部移动到顶部?

问题描述:

如何在Xamarin iOS native中将UITableViewCell从底部移动到顶部?如何在Xamarin iOS中将UITableViewCell从底部移动到顶部?

嗨Xamarin iOS原生的所有社区,我在寻找一个方式在一个UITableView动画一个UITableViewCell,创建一个从底部转移到与任何小区的淡入淡出效果的顶部。

enter image description here

因为所有我找到的例子是斯威夫特,我解决这个问题的答案我自己我将分享社区解决方案。

表源在
+0

欢迎来到堆栈溢出 - 很高兴有你。请阅读[我如何提出一个好问题?](https://*.com/help/how-to-ask)和[如何创建一个最小,完整和可验证的示例](https:// *。 com/help/mcve)帮助将Stack Overflows内容保持在*别,并增加获得正确答案的机会。 – Axel

+0

@Axel https://*.blog/2011/07/01/its-ok-to-ask-and-answer-your-own-questions/ – Dmitry

添加休耕代码

public override void WillDisplay(UITableView tableView, 
UITableViewCell cell, NSIndexPath indexPath) 
    { 
      cell.Alpha = 0; 

      var transform = CoreAnimation.CATransform3D.MakeTranslation(0, 100, 0); 
      cell.Layer.Transform = transform; 

      double delay = indexPath.Row * 0.2; 

      UIView.Animate(1, delay, UIViewAnimationOptions.TransitionFlipFromBottom, 
       () => 
       { 
        cell.Alpha = 1; 
        cell.Layer.Transform = CoreAnimation.CATransform3D.Identity; 
       },finished => { } 
      ); 

    } 

可以在该玩值CoreAnimation.CATransform3D.MakeTranslation(X,Y,Z); X Y Z创建您想要的过渡动画。


double delay = indexPath.Row * 0.2;我为第一次显示de cell时出现延迟的行创建延迟。您可以在不延迟加0

enter image description here

cell.Alpha = 0; 

值这个其他线路许可证隐藏的单元格,当动画开始与淡入淡出效果出现在小区创建动画。

UIView.Animate(1, delay, UIViewAnimationOptions.TransitionFlipFromBottom, 
       () => 
       { 
       cell.Alpha = 1; 
       }, 
       finished => { } 
      ); 
+0

嗨,你的代码是非常有用的。我想用倾倒动画从上到下显示细胞。 –

+0

尝试使用此UIViewAnimationOptions.TransitionFlipFromTop。 –