[英]How to Move Button from Right to Left in Xamarin(iOS)
I am New to Xamarin and iOS. 我是Xamarin和iOS的新手。 I am making App in Visual Studio with Xamarin.
我正在使用Xamarin在Visual Studio中制作App。 I want to move my Button from Right Side to left Side.
我想将我的按钮从右侧移动到左侧。 for that I have use below code :
为此,我使用下面的代码:
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;}
);
My button is moving but it get back to my Previous Position. 我的按钮正在移动,但是回到我的上一个位置。 Any Help be Appreciated.
任何帮助将不胜感激。
This is my Image : 这是我的形象:
UpDate : 更新日期:
When I try different code it work better 当我尝试其他代码时,它会更好地工作
Change Code : 更改代码:
UIView.Animate(2, 0, UIViewAnimationOptions.CurveEaseInOut,
() =>
{
fabButton.Center = new CGPoint(50,611);
},
() =>
{
}
);
Normal Screen : 正常画面:
when Click on button : 当点击按钮时:
But it have some issue The Button is go some height upper side.. 但它有一些问题,“按钮”的高度要高一些。
Ohh It was silly mistake why it goes upper side : 哦,为什么它偏上了,这是一个愚蠢的错误:
I change the code to this way. 我将代码更改为这种方式。
Instead of my point 而不是我的意思
CGPoint(50,611);
to 至
CGPoint(50, fabButton.Center.Y);
because i want move my button to X direction then why I want to change the Y direction value. 因为我想将按钮移到X方向,然后为什么要更改Y方向值。
UIView.Animate(2, 0, UIViewAnimationOptions.CurveEaseInOut,
() =>
{
fabButton.Center = new CGPoint(50,fabButton.Center.Y);
},
() =>
{
}
);
Normal Screen : 正常画面:
After Button Click : 单击按钮后:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.