iOS中的定时器

来源:互联网 发布:淘宝详情页面设计 编辑:程序博客网 时间:2024/06/07 07:43

苹果的定时器通常有两种:NSTimer和CADisplayLink

NSTimer用于计时精度不高的地方

[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(setNeedsDisplay) userInfo:nil repeats:YES];

CADisplayLink用于计时精度较高,而且涉及屏幕动画流畅刷新的地方

// iphone每秒刷新60次// 屏幕刷新的时候就会触发CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)];[link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];

找到一篇更加详细的文章,请参考:
http://www.jianshu.com/p/21d351116587

0 0
原创粉丝点击