0

I have a looping animation like this:

       UIView.Animate(50, 0, UIViewAnimationOptions.Repeat | UIViewAnimationOptions.CurveLinear, () => { 
            bgBackground.Frame = new RectangleF(new PointF(-496, bgBackground.Frame.Y), bgBackground.Frame.Size);
        }, () => {});

but when the app goes to background and the animation is not running.

I've listened for the event when the app comes to foreground but I can't figure out how to restart the animation.

I have another looping animation using CABasicAnimation and that one is still running when resuming the app so can't I use UIView based animations for looping animations?

Other similar questions have just provided CALayer animations as the solution:

Community
  • 1
  • 1
Christer Nordvik
  • 2,518
  • 3
  • 35
  • 52

1 Answers1

0

I rewrote to use CABasicAnimation and then everything works great.

CABasicAnimation animSc;
animSc = CABasicAnimation.FromKeyPath("transform.translation.x");
animSc.From = NSNumber.FromFloat(0.0f);
animSc.To = NSNumber.FromFloat(-496.0f);
animSc.Duration = 50.0f;
animSc.RepeatCount = INFITE_NUMBER;
bgView.Layer.AddAnimation(animSc, "bg_anim");

And then I just call the above code when the view appears and everything starts animating again.

Christer Nordvik
  • 2,518
  • 3
  • 35
  • 52