I have a circle CGRectMake(0.0, 0.0, 100.0, 100.0) with cornerRadius = 100;
I want to move an image around that circle. The image should move around the circle and point to the north. In other words it's a compass, just the heading doesn't rotate, but moves around the circle. Also I need the animation to move forwards and backwards just like on a compass.
Has anyone implemented something like this or have any suggestions or ideas?
Instead of trying to work out the coors of it I'd just have an image that is the same size as the entire compass but completely transparent apart from the pointer which will sit on the top edge.
Then put a UIImageView with this image over your compass and just rotate the image around its centre point.
That way the pointer will always follow a circle and it's easier to point north because you're just dealing with an angle of rotation instead of coordinates.
For calculating the x,y coords for the circle...
x coord = radius * cos(theta).
y coord = radius * sin(theta).
That should do it.
You may have to convert from RADs into degrees.