2016-09-20 33 views
0

XamarinとiOSが新しくなっています。 Visual StudioでXamarinでAppを作成しています。ボタンを右サイドから左サイドに移動したいそのために私は以下のコードを使用しています:Xamarin(iOS)でボタンを右から左に移動する方法

fabButton.SetImage(UIImage.FromFile("Plus Math-24"), UIControlState.Normal); 

      pt = fabButton.Center; 

      UIView.Animate(2, 0, UIViewAnimationOptions.CurveEaseInOut, 
       () => { 

        fabButton.Center = new CGPoint(UIScreen.MainScreen.Bounds.Left - fabButton.Frame.Width/15, fabButton.Center.Y);}, 
      () => { 
       fabButton.Center = pt;} 
      ); 

マイボタンは動いていますが、私の前の位置に戻ります。ヘルプは高く評価されます。

これは私の画像です:

enter image description here

更新:

UIView.Animate(2, 0, UIViewAnimationOptions.CurveEaseInOut, 
       () => 
       { 

        fabButton.Center = new CGPoint(50,611); 
       }, 
      () => 
      { 

      } 
      ); 
:私は別のコードをしようとすると

それがより良い

変更コードを働きます

通常画面:

enter image description here

ボタンをクリックしてください:

enter image description here

しかし、それはボタンがいくつかの高さ上側を行くであるいくつかの問題を持っている...

答えて

0

おおそれがありましたなぜそれが上に行く愚かな間違い:

私は変更このようにコード。代わりに、私のポイントの

CGPoint(50,611); 

CGPoint(50, fabButton.Center.Y);

私はY方向の値を変更したい理由を、次にX方向への私のボタンを移動したいのでへ。

UIView.Animate(2, 0, UIViewAnimationOptions.CurveEaseInOut, 
       () => 
       { 

        fabButton.Center = new CGPoint(50,fabButton.Center.Y); 
       }, 
      () => 
      { 

      } 
      ); 

通常画面:ボタンをクリックした後

enter image description here

enter image description here

関連する問題