1,暂停:
pauseStart = [[NSDate dateWithTimeIntervalSinceNow:0] retain];
previousFireDate = [[timer fireDate] retain];
[timer setFireDate:[NSDate distantFuture]];
2,恢复:
float pauseTime = -1*[pauseStart timeIntervalSinceNow];
[timer setFireDate:[NSDate dateWithTimeInterval:pauseTime sinceDate:previousFireDate]];
just so easy!!
其中 要先声明:两个date对象:
pauseStart, previousFireDate. 还有一个timer对象。NSTimer *timer;