Iphone app - How to show the digital clock with current time -


hello working iphone app need show current time in watch there watch displays static time or static image . need find current time move hrs,mins ,seconds pins such tht should set time. u have ideas here code:

//calculate angles: float minutesangle = (0/60)*360; float hoursangle = (10/12)*360;

//begin animation block [uiview beginanimations:@"movehands" context:nil]; [uiview setanimationduration:0.5]; minsimageview.transform = cgaffinetransformrotate(minsimageview.transform, minutesangle); hoursimageview.transform = cgaffinetransformrotate(hoursimageview.transform, hoursangle); [uiview commitanimations]; 

where minsimageview ,hoursimageview imageviews set in xib shows static image

but not effecting @ all..

once have individual time values (it sounds you've figured out already) can position hands needed.

this means it's time brush on math skills. think this'll give start:

a circle has 360 degrees in it. means whatever time unit get, divide maximum value of time unit fraction , multiply result 360 (instead of 100 percentage) our number of degrees.

so, if had 23 seconds:

23/60 = 3.8333
3.8333 x 360 = 138 degrees

now know how many degrees rotate our object. designer make nice hand images , put them in uiimageviews. then, can rotate them around origins so:

secondhandimage.transform = cgaffinetransformmakerotate(secondangle);

good luck :)

edit: let's assume our hands on 10:10. if wanted move them 01:00 following. tweak needed.

//calculate angles: float minutesangle = (0/60)*360; float hoursangle = (10/12)*360;  //begin 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]; 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -