24 hour analog clock

后端 未结 4 828
醉梦人生
醉梦人生 2020-12-20 08:30

I\'m attempting to make a 24 hour analog clock and currently have a 12 hour clock.

What I wrote:

   currentTime = [NSDate date];
dateComponents = [c         


        
4条回答
  •  伪装坚强ぢ
    2020-12-20 08:47

    I created a project that makes an analog style clock which is available here PSAnalogClock. I used this to work out the hours

    EDIT - thanks to @nes1983

    int hoursFor12HourClock = hours % 12;
    

    Then to calculate the angle I used

    float rotationForHoursComponent  = hoursFor12HourClock * degreesPerHour;
    float rotationForMinuteComponent = degreesPerMinute * [self minutes];
    
    float totalRotation = rotationForHoursComponent + rotationForMinuteComponent;
    

提交回复
热议问题