Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Once you have individual time values (it sounds like you've figured this out already) you can position your hands as needed. </p> <p>This means it's time to brush up on your math skills. I think this'll give you a start:</p> <p>A circle has 360 degrees in it. This means that for whatever time unit we get, we divide by the maximum value of that time unit to get a fraction and multiply the result by 360 (instead of 100 like a percentage) to get our number of degrees. </p> <p>So, if we had 23 seconds:</p> <blockquote> <p>23/60 = 3.8333<br>3.8333 x 360 = 138 degrees</p> </blockquote> <p>Now we know how many degrees to rotate our object. I would get a designer to make you some nice hand images and put them in UIImageViews. Then, you can rotate them around their origins like so:</p> <pre><code>secondHandImage.transform = CGAffineTransformMakeRotate(secondAngle);</code></pre> <p>Good luck :)</p> <p><strong>EDIT:</strong> Let's assume that our hands are on 10:10. If we wanted to move them to 01:00 we would do something like the following. Tweak it as needed. </p> <pre><code>//Calculate angles: float minutesAngle = (0/60)*360; float hoursAngle = (10/12)*360; //Begin the animation block [UIView beginAnimations:@"moveHands" context:nil]; [UIView setAnimationDuration:0.5]; minutesHand.transform = CGAffineTransformRotate(minutesHand.transform, minutesAngle); hoursHand.transform = CGAffineTransformRotate(hoursHand.transform, hoursAngle); [UIView commitAnimations]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload