获取当前时间的时分秒

2016-07-02  本文已影响0人  143db5b5572a

//实例化日历对象

NSCalendar*calendar = [NSCalendarcurrentCalendar];

//获取当前时间的秒数

NSDateComponents*comps = [calendarcomponents:NSCalendarUnitSecondfromDate:[NSDatedate]];

//获取当前时间的分钟数

NSDateComponents*minute = [calendarcomponents:NSCalendarUnitMinutefromDate:[NSDatedate]];

//获取当前时间的分钟数

NSDateComponents*hour = [calendarcomponents:NSCalendarUnitHourfromDate:[NSDatedate]];

// NSLog(@"%.2f", 10/0.3);

//设置秒针的旋转

CGFloatangle =degree2angle(comps.second*360/60);

self.secondView.transform=CGAffineTransformMakeRotation(angle);

//设置分针的旋转

CGFloatangleM =degree2angle(minute.minute*360/60);

self.minuteView.transform=CGAffineTransformMakeRotation(angleM);

//设置时针的旋转

CGFloatangleH =degree2angle(hour.hour*30+ minute.minute/10.0*5);

self.hourView.transform=CGAffineTransformMakeRotation(angleH);

// (hour*30) + (minutes/10)*6

上一篇下一篇

猜你喜欢

热点阅读