I am New to Xamarin and iOS. I am making App in Visual Studio with Xamarin. 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.
UIView.Animate(2, 0, UIViewAnimationOptions.CurveEaseInOut,
() =>
{
fabButton.Center = new CGPoint(50,fabButton.Center.Y);
},
() =>
{
}
);
Normal Screen :
After Button Click :
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.