Alex
Alex

Reputation: 461

Moving Position of View animated

I have a Problem with animating a movement of a View. It works but it stucks if I start animating the movement. Without an animation it works fluently. But if I set the animation it starts stucking. Here is my code:

UIView.BeginAnimations("Slide");
this.detailController.View.Layer.Position = new PointF(50,50);
UIView.CommitAnimations();   

I already tried:

this.detailController.View.Center = new PointF(50,50);

Is there any possibility to make thie animation more fluently ?

Thanks in advance.

Upvotes: 0

Views: 275

Answers (2)

zbMax
zbMax

Reputation: 2818

I'm used to perform my animations like this:

[UIView animateWithDuration:durationTime //in seconds
                     animations:^{
                         //what I want to animate (setCenter:, setFrame:,...)
                     }
                     completion:^(BOOL finished){
                         //only if you want to do things after the animation
                     }
];

Hope it will help you

Upvotes: 1

Stephane Delcroix
Stephane Delcroix

Reputation: 16230

The default animation duration is .2 seconds, which might be too fast to be visible in your case.

If you want fluid animations, play with the duration and the easing functions. Just make sure you set those parameters at the beginning of the animation block (just after BeginAnimation) or they won't be taken into account.

UIView.BeginAnimations("Slide");

UIView.SetAnimationDuration (2);
UIView.SetAnimationCurve (UIViewAnimationCurve.EaseInOut);

detailController.View.Layer.Position = new PointF(50,50);
UIView.CommitAnimations();

For more info, read http://docs.xamarin.com/recipes/ios/animation/coreanimation/animate_a_uiview_using_uikit

Upvotes: 1

Related Questions