【iOS发展-81】setNeedsDisplay刷新显卡,并CADisplayLink它用来模拟计时器效果

it2025-08-07  13

(1)效果

(2)源码下载(假设提示没有小图片的话,自己找一个替换一下即可,看到效果即可)

http://download.csdn.net/detail/wsb200514/8176339

(3)总结:

——由于DrawRect方法仅仅调用1次,所以假设须要刷新图形,须要用setNeedsDisplay强制调用刷新。

——学习还有一种“定时器”的使用方法,下面两种类似

-(void)awakeFromNib{ CADisplayLink *link=[CADisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)]; [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; // [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(setNeedsDisplay) userInfo:nil repeats:YES]; }

版权声明:本文博客原创文章。博客,未经同意,不得转载。

转载于:https://www.cnblogs.com/bhlsheji/p/4729132.html

相关资源:数据结构—成绩单生成器
最新回复(0)