2017-10-18 142 views
2

如何在Xamarin iOS native中將UITableViewCell從底部移動到頂部?如何在Xamarin iOS中將UITableViewCell從底部移動到頂部?

嗨Xamarin iOS原生的所有社區,我在尋找一個方式在一個UITableView動畫一個UITableViewCell,創建一個從底部轉移到與任何小區的淡入淡出效果的頂部。

enter image description here

因爲所有我找到的例子是斯威夫特,我解決這個問題的答案我自己我將分享社區解決方案。

表源在
+0

歡迎來到堆棧溢出 - 很高興有你。請閱讀[我如何提出一個好問題?](https://stackoverflow.com/help/how-to-ask)和[如何創建一個最小,完整和可驗證的示例](https:// stackoverflow。 com/help/mcve)幫助將Stack Overflows內容保持在最高級別,並增加獲得正確答案的機會。 – Axel

+0

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

回答

0

添加休耕代碼

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。 –

相關問題