6

Is there any way to animate uiview moving with cicle trajectory?enter image description here

B.S.
  • 21,660
  • 14
  • 87
  • 109

2 Answers2

4

You will have to create a circular path and animate your view on the path. You can use UIBezierPath to create a circular path . Here is an example that does what exactly you want.

Community
  • 1
  • 1
Vignesh
  • 10,205
  • 2
  • 35
  • 73
4

There are a couple of options. Probably the simplest is to place your view on a parent view, and then animate rotating the parent view around its Z axis.

I guess you could also build a transform that shifts your view, then rotates it, and animate the transform to different rotation values. I'd have to tinker with that. I know the first approach would be quick and easy to set up.

As the other poster said, you could also create a keyframe animation that uses a CGPath to animate your view along a curve that approximated the shape of a circle, but that would be much more work.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • This is a very interesting answer! I can't believe I didn't think of before! It's by far the simplest answer if all you have to do is to rotate in a circular path! – M. Porooshani Dec 21 '15 at 10:28