NSTime 定时器
// 创建一个定时器
NSTime timer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(nextPage) userInfo:nil repeats:YES];
// 将定时器加入主运行循环
[[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
// 将NSTime赋值给自己的成员变量
self.time = time;
// 将定时器停止
[self.timer invalidate];
// 将定时器暂停
// 创建时钟对象
self.time = [CADisplayLink displayLinkWithTarget:self selector:@selector(step)];
// 将时钟添加到主运行循环
[self.time addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
// 将定时器停止
[self.timer invalidate];
// 将定时器暂停
self.time.paused = !self.time.paused;
网友评论