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;
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。